Table.Unpivot

Table

Transforms specified columns into attribute-value pairs, normalizing a wide table into a tall, narrow format.

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

Syntax

Table.Unpivot(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 unpivot into rows.
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 the specified columns unpivoted into rows of attribute-value pairs.

Remarks

Table.Unpivot converts selected columns into rows, producing a pair of new columns: one for the original column names (the attribute column) and one for their values (the value column). All columns not listed in pivotColumns are repeated for each unpivoted row.

This is the inverse of Table.Pivot and is useful for normalizing wide datasets where measures are spread across multiple columns into a format suitable for analysis or visualization.

Important: Null values are silently removed during an unpivot operation — any cell that contains null will not produce a row in the output. If you need to preserve the fact that a value was missing, replace nulls with a placeholder (e.g., 0 or "N/A") using Table.ReplaceValue before unpivoting.

Examples

Example 1: Unpivot UnitPrice and Quantity into attribute-value pairs

let
    Source = Table.SelectColumns(
        Table.FirstN(Sales, 3),
        {"Product", "UnitPrice", "Quantity"}
    )
in
    Table.Unpivot(Source, {"UnitPrice", "Quantity"}, "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