Sintaxe
M
Table.Pivot(table as table, pivotValues as list, attributeColumn as text, valueColumn as text, optional aggregationFunction as nullable function) as tableParâmetros
- tabletableObrigatório
Tabela com os pares atributo-valor.
MTable.FromRecords({[key = "x", attribute = "a", value = 1], ...})- pivotValueslistObrigatório
Valores da coluna de atributo que viram novas colunas.
M{"a", "b", "c"}- attributeColumntextObrigatório
Nome da coluna de atributo.
M"attribute"- valueColumntextObrigatório
Nome da coluna de valores.
M"value"- aggregationFunctionnullable functionOpcional
Função usada para resolver vários valores para o mesmo atributo e chave.
Retorna
tableExemplo
M
Table.Pivot(
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]
}),
{"a", "b", "c"},
"attribute",
"value"
)Resultado
M
Table.FromRecords({
[key = "x", a = 1, b = null, c = 3],
[key = "y", a = 2, b = 4, c = null]
})Mais informações
- Subgrupo
- Table