Aggregate
Turns a list of items into a single result: a total, an average, a list of values, groups, or one object wrapping everything. It is the opposite of Split Out.
Parameters
| Name | Required | Default | Description |
|---|---|---|---|
Items (input) | Yes | — | The array to aggregate, e.g. {{ $nodes['Fetch Orders'].items }}. |
Aggregate (mode) | Yes | A field across all items | field — apply an operation to one field of every item. groupBy — group items by a field. allItems — wrap all items into one object. |
Group by field (groupBy) | Group by mode | — | Field (path) to group on, e.g. customer.country. |
Field (field) | No | The item itself | Field (path) to read from each item, e.g. price. Shown in field and groupBy modes. |
Operation (operation) | No | List values | What to compute — see Operations. Shown in field and groupBy modes. |
Separator (separator) | No | , | Used by Concatenate. |
Output field name (outputField) | No | value (field mode) / items (all items mode) | Rename the result field. |
Field paths use dots and brackets: customer.address.city, lines[0].sku.
Operations
| Operation | Value | Result |
|---|---|---|
| List values | list | Every value, including empty ones, in order. |
| Sum | sum | Sum of the numeric values (whole numbers stay integers). |
| Average | average | Mean of the numeric values, or null if there are none. |
| Minimum / Maximum | min / max | Smallest / largest non-empty value (numbers numerically, text alphabetically). |
| Count (non-empty) | count | How many values are not null. |
| Unique values | unique | Distinct non-empty values, in first-seen order. |
| Count unique | countUnique | How many distinct non-empty values. |
| Concatenate | concatenate | Non-empty values joined with Separator. |
Values that aren't numbers are ignored by Sum and Average; numeric text such as "12.50" counts as a number.
Ports
| Port | Description |
|---|---|
main (input) | The step(s) Aggregate runs after. |
output | Shape depends on the mode — see below. |
Output
A field across all items — field = amount, operation = Sum:
{ "value": 1290, "count": 4 }
count is the number of input items.
Group by a field — groupBy = country, field = amount, operation = Sum:
{
"groups": [
{ "key": "GB", "items": [ { "id": 1, "country": "GB", "amount": 500 }, { "id": 3, "country": "GB", "amount": 290 } ], "count": 2, "value": 790 },
{ "key": "DE", "items": [ { "id": 2, "country": "DE", "amount": 500 } ], "count": 1, "value": 500 }
],
"count": 2
}
Each group has key, its items and their count. value is only added when a Field is set and the operation isn't List values. The top-level count is the number of groups.
All items into one object:
{ "items": [ { "id": 1 }, { "id": 2 } ], "count": 2 }
Example
Build a comma-separated list of customer emails for a notification:
- Items:
{{ $nodes['Get Customers'].items }} - Aggregate: A field across all items
- Field:
email - Operation: Concatenate
- Separator:
, - Output field name:
recipients
Result: { "recipients": "ada@example.com, alan@example.com", "count": 2 } — use it as {{ $nodes['Aggregate'].recipients }}.
Notes
- Groups appear in the order their first item appears.
- Items must resolve to an array (a single value is a one-item list; an empty value an empty list). Stored files must be parsed first.