Table.ExpandTableColumn

Table

Expands a column of nested tables into individual columns in the parent table.

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

Syntax

Table.ExpandTableColumn(table as table, column as text, columnNames as list, optional newColumnNames as nullable list) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe input table containing a column of nested tables.
columntextYesThe name of the column containing nested tables to expand.
columnNameslistYesA list of column names from the nested table to extract.
newColumnNameslistNoOptional list of new names for the expanded columns. If omitted, the original nested column names are used.

Return Value

tableThe input table with the specified nested table column expanded into separate columns.

Remarks

Table.ExpandTableColumn takes a column that contains nested tables (typically the result of Table.NestedJoin or Table.Group) and flattens selected columns from those nested tables into the parent table.

Use the optional newColumnNames parameter to rename the expanded columns in the same step, rather than adding a separate Table.RenameColumns call. This keeps your query concise and reduces unnecessary steps.

Only expand the columns you actually need. Expanding all columns from a nested table and then removing most of them wastes processing time.

Examples

Example 1: Expand columns from a join result

let
    Joined = Table.NestedJoin(
        Table.SelectColumns(Table.FirstN(Sales, 3), {"CustomerName", "Product"}),
        "CustomerName", Customers, "Name",
        "CustData", JoinKind.LeftOuter
    )
in
    Table.ExpandTableColumn(Joined, "CustData", {"City", "State"}, {"Customer City", "Customer State"})
Result
CustomerName
Product
Customer City
Customer State
1AliceWidget ANew YorkNY
2BobGadget BChicagoIL
3CharlieWidget CHoustonTX

Compatibility

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