Aggregate
Description
Section titled “Description”The Aggregate node turns a list of records into figures: how many there are, what they add up to, the average amount, the largest, the oldest… Without grouping it returns a single object; if you set a grouping field it returns one row per group (sales per product, leads per status, tickets per owner) and you can sort them and keep the first ones.
It understands numbers written with a decimal comma ("20,5"). Anything that is not a number is ignored in sums, averages, minimums and maximums; if a column has no numbers at all (for example YYYY-MM-DD dates), minimum and maximum compare the texts.
Configuration
Section titled “Configuration”| Parameter | Type | Required | Description |
|---|---|---|---|
| path | text | No | Path to the list (orders, data.items…). Empty = the incoming data (or items / data if they are a list) |
| metrics | textarea | Yes | Metrics name=operation:field, one per line or comma-separated |
| groupBy | text | No | Field to group by (paths such as customer.country work) |
| sortBy | text | No | With groups: name of a metric or of the grouping field; with a leading -, descending |
| limit | number | No | With groups: maximum rows (top N). Empty or 0 = all |
| decimals | number | No | Rounding of sums and averages, 0 to 10 (default 2) |
| outputKey | text | No | Output field (default resumen) |
Operations
Section titled “Operations”| Operation | Result |
|---|---|
count | Number of items. With a field (count:email), only those where it is filled in |
sum:field | Sum of the numeric values |
avg:field | Average of the numeric values (null if there are none) |
min:field / max:field | Minimum / maximum (numbers or, if there are no numbers, texts such as ISO dates) |
first:field / last:field | First / last filled-in value |
distinct:field | How many distinct values there are |
join:field | The values joined with commas (handy for a text summary) |
Output
Section titled “Output”Without grouping, with metrics = "orders=count, total=sum:amount":
{ "resumen": { "orders": 5, "total": 35.75 }, "count": 5}Grouping by product, with sortBy = "-total":
{ "resumen": [ { "product": "B", "orders": 1, "total": 20.25 }, { "product": "A", "orders": 3, "total": 15.5 } ], "count": 5}The node keeps the incoming data and adds the result and count (items in the list). If what arrives is directly a list (for example, the output of an Array Filter), the list is kept in items, so you can use it afterwards with List to Text (source: items). Records with no value in the grouping field form one group with an empty value.
Usage Examples
Section titled “Usage Examples”Top 5 products by sales
Section titled “Top 5 products by sales”{ "label": "Top products", "path": "orders", "metrics": "sales=sum:total, orders=count", "groupBy": "product", "sortBy": "-sales", "limit": 5, "outputKey": "top"}Combine it with the List to Text node (source: top) to build the report message.
This week’s figures
Section titled “This week’s figures”{ "label": "Weekly summary", "path": "sales", "metrics": "total=sum:amount, average_ticket=avg:amount, largest=max:amount, customers=distinct:customer_id, first=min:date"}Related Nodes
Section titled “Related Nodes”- arrayFilter (Array Filter - to keep the records you care about before summarizing)
- arrayGroupBy (Array Group By - groups without computing metrics)
- listToText (List to Text - to turn the result into text or a table)