Table.CombineColumnsToRecord
Gathers several columns into one column of records, a field per column.
Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Table.CombineColumnsToRecord(table as table, newColumnName as text, sourceColumns as list, optional options as nullable record) as table
| Parameter | Type | Description |
|---|---|---|
table | table | The table with the columns. |
newColumnName | text | The name of the record column. |
sourceColumns | list | The columns that become the records' fields. |
options | nullable record optional | Options for the new column. |
Returns
table. The table with the source columns replaced by the record column.
Remarks
Table.ExpandRecordColumntakes the fields out again.
Examples
An address record
let
Shops = #table({"Shop", "Street", "City"}, {{"Oslo", "Storgata 1", "Oslo"}, {"Bergen", "Torget 2", "Bergen"}})
in
Table.CombineColumnsToRecord(Shops, "Address", {"Street", "City"})
| Shop | Address |
|---|---|
| Oslo | [Street = "Storgata 1", City = "Oslo"] |
| Bergen | [Street = "Torget 2", City = "Bergen"] |
Related functions
Table.ExpandRecordColumn, Table.CombineColumns, Table.ToRecords.