OpenBI Docs Buy

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
ParameterTypeDescription
tabletableThe table in wide form.
pivotColumnslistThe columns to keep as they are; all the others become rows.
attributeColumntextThe name of the new column for the old column names.
valueColumntextThe 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")
ShopMonthSales
OsloJan10
OsloFeb12
OsloMar9
BergenJan7
BergenFeb8
BergenMar11

Table.Unpivot, Table.Pivot, Table.Group.

Last updated · OpenBI Studio 0.3.79