Power QueryExercises

Table.Group

Table function · By Tahir Nas · Examples run in our simulator · Published · Updated

Groups rows by key columns and aggregates each group.

When to use it

Use it to summarise rows per key (totals, counts, min and max), or with All Rows to keep each group's table for further work such as top N per group. It replaces most pivot-table style summaries.

Syntax

Table.Group(table as table, key as any, aggregatedColumns as list, optional groupKind as nullable number, optional comparer as nullable function) as table

Parameters

key
Column name(s) to group by.
aggregatedColumns
A list of {name, function, type}; the function receives the group's table.

Returns

One row per distinct key with the aggregations.

Example

Table.Group(#table({"Region", "Product", "Qty"}, {{"North", "Kite", 2}, {"South", "Reel", 5}, {"North", "Reel", 1}, {"West", "Kite", 4}}), {"Product"}, {{"Total", each List.Sum([Qty]), type number}, {"Rows", each Table.RowCount(_), Int64.Type}})

Result

ProductTotalRows
Kite62
Reel62

Example: count and sum per region

Each aggregation receives the group's rows as a table, so Table.RowCount(_) counts them.

Table.Group(#table({"Region", "Rep", "Amount"}, {{"North", "Ana", 120}, {"South", "Bo", 80}, {"North", "Cy", 200}, {"South", "Ana", 50}}), {"Region"}, {{"Orders", each Table.RowCount(_), Int64.Type}, {"Total", each List.Sum([Amount]), type number}})

Result

RegionOrdersTotal
North2320
South2130

Both results are produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M, and checked on every build.

Good to know

Common mistakes

The matching command in Excel

Excel for Windows
Transform > Group By (also on the Home tab)
What you see
The Group By dialog sets the key columns and one new column per aggregation.

Paths are for the Power Query editor in Excel for Microsoft 365, checked against Microsoft's documentation on 8 November 2026: Grouping or summarizing rows (Microsoft Learn).

Exercises that use Table.Group

Learn more

Related functions

Official documentation: Table.Group on Microsoft Learn.