OpenBI Docs Buy

Table.ExpandRecordColumn

Spreads a column of records into one column per field you name.

Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Table.ExpandRecordColumn(table as table, column as text, fieldNames as list, optional newColumnNames as nullable list) as table
ParameterTypeDescription
tabletableThe table with a column of records.
columntextThe column that holds the records.
fieldNameslistThe records' fields to bring out.
newColumnNamesnullable list
optional
Names for the new columns, in the same order; the field names when left out.

Returns

table. The table with the record column replaced by the new columns.

Remarks

  • A record without one of the fields gives null in that field's column.

Examples

A shop's address in columns

let
    Shops = #table({"Shop", "Address"}, {
        {"Oslo", [Street = "Storgata 1", City = "Oslo"]},
        {"Bergen", [Street = "Torget 2", City = "Bergen"]}})
in
    Table.ExpandRecordColumn(Shops, "Address", {"Street", "City"})
ShopStreetCity
OsloStorgata 1Oslo
BergenTorget 2Bergen

Some fields, new names

let
    Orders = #table({"Order", "Customer"}, {
        {1, [Name = "Nordvik AS", Country = "NO"]},
        {2, [Name = "Fjell AB"]}})
in
    Table.ExpandRecordColumn(Orders, "Customer", {"Country"}, {"Customer country"})
OrderCustomer country
1NO
2null

The second record has no Country field: null.

Table.ExpandTableColumn, Table.ExpandListColumn, Table.CombineColumnsToRecord, Record.Field.

Last updated · OpenBI Studio 0.3.79