Table.CombineColumnsToRecord

Table

Combines selected columns into a single record column.

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

Syntax

Table.CombineColumnsToRecord(table as table, newColumnName as text, sourceColumns as list, optional options as nullable record) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe table to process.
newColumnNametextYesThe name of the new record column.
sourceColumnslistYesA list of column names to combine into a record.
optionsrecordNoOptional record. Supports DisplayNameColumn (text) to specify which field name to use as the display name for the record column.

Return Value

tableThe original table with the specified columns replaced by a single record column.

Remarks

Table.CombineColumnsToRecord packages multiple columns into a single column where each cell is a record. The source columns are removed and replaced by the new record column. This is useful for passing structured sub-objects downstream or for reshaping data before expanding with Table.ExpandRecordColumn.

The field names in the resulting records match the original column names.

Examples

Example 1: Combine address columns into a record

Table.CombineColumnsToRecord(
    #table({"Name", "City", "Country"}, {{"Alice", "Paris", "France"}, {"Bob", "Tokyo", "Japan"}}),
    "Address",
    {"City", "Country"}
)
Result
Name
Address
1Alice[City = "Paris", Country = "France"]
2Bob[City = "Tokyo", Country = "Japan"]

Example 2: Round-trip with ExpandRecordColumn

let
    Source   = #table({"ID", "X", "Y"}, {{1, 10, 20}, {2, 30, 40}}),
    Combined = Table.CombineColumnsToRecord(Source, "Coords", {"X", "Y"}),
    Expanded = Table.ExpandRecordColumn(Combined, "Coords", {"X", "Y"})
in
    Expanded
Applied Steps

The final output — expands the Coords record column back into separate X and Y columns, restoring the original flat structure.

ID
X
Y
111020
223040

Compatibility

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