Skip to main content

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​

NameRequiredDefaultDescription
Items (input)Yes—The array to aggregate, e.g. {{ $nodes['Fetch Orders'].items }}.
Aggregate (mode)YesA field across all itemsfield — 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)NoThe item itselfField (path) to read from each item, e.g. price. Shown in field and groupBy modes.
Operation (operation)NoList valuesWhat to compute — see Operations. Shown in field and groupBy modes.
Separator (separator)No, Used by Concatenate.
Output field name (outputField)Novalue (field mode) / items (all items mode)Rename the result field.

Field paths use dots and brackets: customer.address.city, lines[0].sku.

Operations​

OperationValueResult
List valueslistEvery value, including empty ones, in order.
SumsumSum of the numeric values (whole numbers stay integers).
AverageaverageMean of the numeric values, or null if there are none.
Minimum / Maximummin / maxSmallest / largest non-empty value (numbers numerically, text alphabetically).
Count (non-empty)countHow many values are not null.
Unique valuesuniqueDistinct non-empty values, in first-seen order.
Count uniquecountUniqueHow many distinct non-empty values.
ConcatenateconcatenateNon-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​

PortDescription
main (input)The step(s) Aggregate runs after.
outputShape 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.