group-by
The group-by function creates groups of records according to some grouping key that you specify.
For example, in the abstract transformation illustrated below, the grouping key is "Department". Since there are three unique departments in total, applying the group-by function would create three groups:
Languages
Built-in, C++, C#, Java, XSLT 2.0, XSLT 3.0.
Parameters
Name | Description |
---|---|
nodes/rows | This input must receive a connection from a mapping item that provides a sequence of zero or more values. For example, the connection may originate from a source XML item. |
key | The key by which to group items. |
Example
Let's assume that your source data is an XML file with the following content (note that, in the code listing below, the namespace and XML declarations were removed for simplicity).
<company> |
The business requirement is to group person records by department. To achieve this, the following mapping invokes the group-by function, and supplies department as key.
The mapping result is as follows:
<groups> |
This example, together with other grouping examples, is part of the following mapping file: <Documents>\Altova\MapForce2023\MapForceExamples\Tutorial\GroupingFunctions.mfd. Remember to click the Preview button applicable to the function you want to preview, before clicking the Output pane.