Table.AggregateTableColumn

Table

Expands a column of nested tables by applying aggregation functions to each nested table.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Table.AggregateTableColumn(table as table, column as text, aggregations as list) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe table containing a column of nested tables.
columntextYesThe name of the column containing nested tables.
aggregationslistYesA list of {newColumnName, aggregationFunction, newColumnType} triples defining how each nested table is aggregated.

Return Value

tableThe original table with the nested table column replaced by aggregated result columns.

Remarks

Table.AggregateTableColumn is an alternative to Table.ExpandTableColumn when you want to aggregate (rather than flatten) the nested tables in a column. Each aggregation is defined as a three-element list: {newColumnName, aggregationFunction, newColumnType}.

The aggregationFunction receives the nested table as its argument and returns a scalar result. Common choices include Table.RowCount, List.Sum, List.Max, etc.

This is particularly useful after a Table.Group or Table.NestedJoin step when you want summary statistics instead of expanded rows.

Examples

Example 1: Count rows in each nested table

let
    Source = Table.Group(
        #table({"Dept", "Salary"}, {{"HR", 50000}, {"IT", 80000}, {"HR", 60000}}),
        "Dept",
        {{"Employees", each _, type table}}
    )
in
    Table.AggregateTableColumn(Source, "Employees", {{"Count", Table.RowCount, type number}})
Result
Dept
Count
1HR2
2IT1

Example 2: Sum a column in each nested table

let
    Grouped = Table.Group(
        #table({"Region", "Sales"}, {{"North", 100}, {"North", 200}, {"South", 150}}),
        "Region",
        {{"Data", each _, type table}}
    )
in
    Table.AggregateTableColumn(Grouped, "Data", {{"TotalSales", each List.Sum([Sales]), type number}})
Result
Region
TotalSales
1North300
2South150

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks