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
| Parameter | Type | Description |
|---|---|---|
table | table | The table with a column of records. |
column | text | The column that holds the records. |
fieldNames | list | The records' fields to bring out. |
newColumnNames | nullable 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"})
| Shop | Street | City |
|---|---|---|
| Oslo | Storgata 1 | Oslo |
| Bergen | Torget 2 | Bergen |
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"})
| Order | Customer country |
|---|---|
| 1 | NO |
| 2 | null |
The second record has no Country field: null.
Related functions
Table.ExpandTableColumn, Table.ExpandListColumn, Table.CombineColumnsToRecord, Record.Field.