Table.UnpivotOtherColumns

MTabela

Converte todas as colunas, exceto as indicadas em pivotColumns, em pares atributo-valor, combinados com os demais valores de cada linha.

Sintaxe

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

Parâmetros

tabletableObrigatório

Tabela de origem.

M
Table.FromRecords({[key = "key1", attribute1 = 1, attribute2 = 2, attribute3 = 3], ...})
pivotColumnslistObrigatório

Colunas que permanecem como estão; as demais viram pares atributo-valor.

M
{"key"}
attributeColumntextObrigatório

Nome da nova coluna de atributo.

M
"column1"
valueColumntextObrigatório

Nome da nova coluna de valor.

M
"column2"

Retorna

table

Exemplo

M
Table.UnpivotOtherColumns(
    Table.FromRecords({
        [key = "key1", attribute1 = 1, attribute2 = 2, attribute3 = 3],
        [key = "key2", attribute1 = 4, attribute2 = 5, attribute3 = 6]
    }),
    {"key"},
    "column1",
    "column2"
)

Resultado

M
Table.FromRecords({
    [key = "key1", column1 = "attribute1", column2 = 1],
    [key = "key1", column1 = "attribute2", column2 = 2],
    [key = "key1", column1 = "attribute3", column2 = 3],
    [key = "key2", column1 = "attribute1", column2 = 4],
    [key = "key2", column1 = "attribute2", column2 = 5],
    [key = "key2", column1 = "attribute3", column2 = 6]
})

Mais informações

Subgrupo
Table

Aprender Power Query ao vivo