Group By
Group By
Section titled “Group By”Type: group-by · Package: DataTable Activities v1.0.0 · Output: DataTable
Groups rows by values in a column and calculates one or more aggregates per group, returning a summary table. It is the equivalent of a pivot table: “total sales per customer”, “number of orders per state”, “average per region”.
How it works
Section titled “How it works”Gather the rows that share the same value into the grouping column and, for each group, calculate the aggregations that you define. The result is a new table with one row per group: the grouping column plus one column for each aggregate.
Required parameters
Section titled “Required parameters”| Parameter | Editor | Description |
|---|---|---|
table | expression | The DataTable to group. |
column | text | Column to group by. |
aggregations | arreglo | List of {column, operation, alias} objects. operation: sum · count · avg · min · max. alias is the name of the resulting column. |
Optional parameters
Section titled “Optional parameters”Ninguno.
Output
Section titled “Output”Returns a DataTable with one row per group: the grouping column and one column per aggregate (named after its alias).
Example
Section titled “Example”Total and number of invoices per client. In the Designer, aggregations are defined with a visual editor: for each one you choose column, operation and an alias (name of the resulting column).
Group By table = = facturas column = "Cliente" aggregations: Total · sum → alias "TotalCliente" Total · count → alias "NumFacturas" → output: resumenPorClienteThe result has columns
Cliente,TotalClienteandNumFacturas, with one row per customer.
Related activities
Section titled “Related activities”- Aggregate Column — a global (ungrouped) aggregate.
- Sort DataTable — sort the resulting summary.
- Filter DataTable — acotar antes de agrupar.