Converting a List Into a Grouped List
You may need to convert a flat list of items into a more structured list.
For example, you may have a list of all orders that have been completed. You might want to organize that list so that you can group the orders placed by each customer.
- Procedure
- Choose the repeating element in the function input schema that holds the grouped data. In this example, that element is
Orders
. Right-click on this element and choose from the pop-up menu. This is a shortcut to create a For-Each-Group statement with theOrders
element as a child element and a Grouping statement to contain the element you wish to group-by.Adding the Grouping statement creates the
$=current-group()
element in the Scope Variables area. The Grouping statement creates the list grouped by the desired element, and thecurrent-group()
function allows you to access the items in theRequests
repeating element that correspond to the group that is currently being processed. - Drag the repeating element from the Scope Variables area to the For-Each-Group statement.
- Drag the element you wish to group by from the Scope Variables area to the Grouping statement in the Function panel. In this example, customerID is the grouping element.
- Map the
current-group()
element in the Scope Variables area to the repeating element Order under the Customer element in the Function panel.The default choice in the mapping wizard for this mapping is to create a For-Each. Choose this option in the mapping wizard.
This creates an item in the
Order
list for each item in the current customer ID group that is being processed. The mapping wizard asks if you wish to map items with the same name in the current group and the orders group. - Map the remaining element from the
current-group()
element into the desired element in the For-Each group. In this case,quantity
would map toQuantity
automatically, andItem
must be mapped toItemName
. - Map the customerID element in the Requests element into the Customer element in the Function panel.