Applying functions to collections of elements - 8.0

Talend Data Mapper Functions Reference Guide

Version
8.0
Language
English
Product
Talend Big Data Platform
Talend Data Fabric
Talend Data Management Platform
Talend Data Services Platform
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development > Designing Jobs
Last publication date
2023-10-26

Use the AgMaximum, AgMinimum and AgAverage functions with a SimpleLoop expression to collect multiple input elements and calculate the highest, lowest and average values for these elements.

Before you begin

You have created a map with an input and output structure. You can use the samples provided below.

About this task

In this example, you have a CSV file containing employee information, including salaries. You want to create an XML file indicating the highest, lowest and average salaries. You can use the following CSV sample as input:
firstName,lastName,salary
Steve,Rogers,185
Tony,Stark,200
Natasha,Romanoff,175
Bruce,Banner,150
Clint,Barton,135
You can use the following XML sample to create your output structure:
<root>
	<highest/>
	<lowest/>
	<average/>
</root>

Procedure

  1. Drag and drop an AgMaximum function on the highest element.
  2. Drag and drop the input salary element on the AgMaximum function.
    A loop expression is added.
  3. Drag and drop an AgMinimum function on the lowest element and drop the salary element on it.
  4. Drag and drop an AgAverage function on the average element and drop the salary element on it.

Results

Your map in configured, you can click Test Run to see the output. It should look like this:
<root>
  <highest>200</highest>
  <lowest>135</lowest>
  <average>169</average>
</root>