Skip to main content Skip to complementary content

Applying functions to collections of elements

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>

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!