Mapping Looping to Non-Looping
Aggregate functions (shown in example Maps/Looping/LoopAggregate - look at the /Notices/Notice/TotalsItems element) are used in this case where you most often want to map a sum or a concatenation of many values. Other uses for aggregate functions are selecting a particular instance from the input loop. To use an aggregate function, simply map it to the value expression in the output map element. In the case below, we want the TotalItems in the output to be the count of all Items (represented by PartNumber) in the input.

You can see below that for each argument of the aggregate function, a loop expression is required. This loop expression provides the context for its argument. In this case, we are just doing a simple loop to get all of the values of PartNumber in the Item loop. The context for this loop is implicitly the loop context of the enclosing output map element, which in this case is Notice. You can change the context to use a higher-level loop (if you wanted to count all of the Items for all POs, for example) by using the EnclosingContext function.
