Table.UnpivotOtherColumns
Turns every column except those you name into rows of two columns: the old column's name and its value.
Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Table.UnpivotOtherColumns(table as table, pivotColumns as list, attributeColumn as text, valueColumn as text) as table
| Parameter | Type | Description |
|---|---|---|
table | table | The table in wide form. |
pivotColumns | list | The columns to keep as they are; all the others become rows. |
attributeColumn | text | The name of the new column for the old column names. |
valueColumn | text | The name of the new column for their values. |
Returns
table. The columns you named, then the two new ones: a row per old row and other column.
Remarks
- A column that appears in the source later becomes rows too, without changing the query.
- A null cell gives no row.
Examples
Every month into rows
Table.UnpivotOtherColumns(#table({"Shop", "Jan", "Feb", "Mar"}, {{"Oslo", 10, 12, 9}, {"Bergen", 7, 8, 11}}), {"Shop"}, "Month", "Sales")
| Shop | Month | Sales |
|---|---|---|
| Oslo | Jan | 10 |
| Oslo | Feb | 12 |
| Oslo | Mar | 9 |
| Bergen | Jan | 7 |
| Bergen | Feb | 8 |
| Bergen | Mar | 11 |