Table.UnpivotOtherColumns

Table

Unpivots all columns except the specified ones into attribute-value pairs.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Table.UnpivotOtherColumns(table as table, pivotColumns as list, attributeColumn as text, valueColumn as text) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe input table containing columns to unpivot.
pivotColumnslistYesA list of column names to keep as-is (not unpivoted).
attributeColumntextYesThe name of the new column that holds the original column names.
valueColumntextYesThe name of the new column that holds the values from the unpivoted columns.

Return Value

tableA table with all non-specified columns unpivoted into rows of attribute-value pairs.

Remarks

Table.UnpivotOtherColumns is the complement of Table.Unpivot. Instead of specifying which columns to unpivot, you specify which columns to keep — everything else gets unpivoted into attribute-value pairs.

This is generally preferred over Table.Unpivot when the source table may gain new columns over time (e.g., new months, new product lines). With Table.UnpivotOtherColumns, new columns are automatically unpivoted without changing your query. With Table.Unpivot, you would need to update the column list manually.

Important: Like Table.Unpivot, null values are silently removed during the unpivot operation. Replace nulls with a placeholder using Table.ReplaceValue before unpivoting if you need to preserve missing values.

Examples

Example 1: Unpivot all columns except Product

let
    Source = Table.SelectColumns(Table.FirstN(Sales, 3), {"Product", "UnitPrice", "Quantity"})
in
    Table.UnpivotOtherColumns(Source, {"Product"}, "Measure", "Value")
Result
Product
Measure
Value
1Widget AUnitPrice25
2Widget AQuantity4
3Gadget BUnitPrice50
4Gadget BQuantity2
5Widget CUnitPrice15
6Widget CQuantity10

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks