Table.Unpivot

Syntax

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

About

Translates a set of columns in a table into attribute-value pairs, combined with the rest of the values in each row.

Example 1

Take the columns "a", "b", and "c" in the table ({[ key = "x", a = 1, b = null, c = 3 ], [ key = "y", a = 2, b = 4, c = null ]}) and unpivot them into attribute-value pairs.

Table.Unpivot(
    Table.FromRecords({
        [key = "x", a = 1, b = null, c = 3],
        [key = "y", a = 2, b = 4, c = null]
    }),
    {"a", "b", "c"},
    "attribute",
    "value"
)
key attribute value
x a 1
x c 3
y a 2
y b 4