Groups rows in the table that have the same key.

function (table as table, optional key as nullable any, aggregatedColumns as list, optional groupKind as nullable any, optional comparer as nullable function) as table


Groups the rows of table by the values in the specified column,key, for each row. For each group, a record is constructed containing the key columns (and their values) along with any aggregated columns specified by aggregatedColumns. Note if multiple keys match the comparer, different keys may be returned. This function cannot guarantee to return a fixed order of rows. Optionally, groupKind and comparer may also be specifed.




Group the table adding an aggregate column [total] which contains the sum of prices ("each List.Sum([price])").

Table.Group(Table.FromRecords({[CustomerID= 1, price = 20], [CustomerID= 2, price = 10], [CustomerID= 2, price = 20], [CustomerID= 1, price = 10], [CustomerID= 3, price = 20], [CustomerID= 3, price = 5]}), "CustomerID", {"total",each List.Sum([price])})

Table.FromRecords({ [CustomerID= 1, total = 30], [CustomerID= 2, total = 30], [CustomerID= 3, total = 25]}, {"CustomerID", "total"})