Skip to content

Array Group By

The Array Group By node takes an array of objects and groups them by the value of a specified field (dot-notation supported). The result is an object where each key is a unique value found in the field, and its value is the sub-array of matching elements.

For example, given 10 records with country values of ES, FR, and ITA, the node returns 3 sub-arrays, one per country, plus metadata (_groups, _groupCount, _total).

It supports nested fields (address.country), variables from other nodes in the source field, and an optional array format (_groupsArray) for use with the Iterator node.

ParameterTypeRequiredDescription
sourcetextNoDot-notation path to the array within the data. If empty, uses data directly. Example: items, result.rows
groupBytextYesDot-notation path of the field to group by. Example: country, address.country, status
outputFormatselectNoobject (default): only the grouped object. array: also adds _groupsArray for iteration with Iterator
{
"ES": [
{ "name": "Ana", "country": "ES" },
{ "name": "Luis", "country": "ES" }
],
"FR": [
{ "name": "Pierre", "country": "FR" },
{ "name": "Marie", "country": "FR" }
],
"ITA": [
{ "name": "Marco", "country": "ITA" }
],
"_groups": ["ES", "FR", "ITA"],
"_groupCount": 3,
"_total": 5,
"_ungrouped": 0
}

Adds the _groupsArray field for iteration:

{
"ES": [...],
"FR": [...],
"ITA": [...],
"_groups": ["ES", "FR", "ITA"],
"_groupCount": 3,
"_total": 5,
"_ungrouped": 0,
"_groupsArray": [
{ "key": "ES", "items": [...], "count": 2 },
{ "key": "FR", "items": [...], "count": 2 },
{ "key": "ITA", "items": [...], "count": 1 }
]
}
{
"label": "Group by Country",
"groupBy": "country"
}
{
"label": "Group by Province",
"groupBy": "address.province"
}

Array from a previous node + Iterator format

Section titled “Array from a previous node + Iterator format”
{
"label": "Group Orders",
"source": "orders",
"groupBy": "status",
"outputFormat": "array"
}

Then connect to an Iterator on _groupsArray to process each group independently.

{
"label": "Group by Status",
"source": "{{@SqlQuery.rows}}",
"groupBy": "status"
}
FieldDescription
{key}Sub-array of elements for each unique value found
_groupsArray with the names of all found groups
_groupCountTotal number of distinct groups
_totalTotal number of elements in the original array
_ungroupedNumber of elements that had no value in the groupBy field (grouped under __sin_valor__)
_groupsArray(Only with outputFormat: array) Array of {key, items, count} for iteration
  • Records without a value in the groupBy field are grouped under the key __sin_valor__
  • The source field supports dynamic variables: {{@NodeName.field}}, {{#N.field}}
  • Does not require credentials
  • Compatible with the Iterator node using _groupsArray to process each group as a separate flow
  • If the input is not an array, returns an error with a descriptive message