Pular para o conteúdo principal

Table.Unpivot

Converte um conjunto de colunas de uma tabela em pares de atributo/valor.

Syntax

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

Remarks

Converte um conjunto de colunas de uma tabela em pares de atributo/valor, combinados com o restante dos valores em cada linha.

Examples

Example #1

Transforme as colunas "a", "b" e "c" da tabela <code>({[ key = "x", a = 1, b = null, c = 3 ], [ key = "y", a = 2, b = 4, c = null ]})</code> em pares de atributo/valor.

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"
)

Result:

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

Category

Table.Column operations