Školení
Modul
Transform data by implementing pivot, unpivot, rollup, and cube - Training
This content is a part of Transform data by implementing pivot, unpivot, rollup, and cube.
Tento prohlížeč se už nepodporuje.
Upgradujte na Microsoft Edge, abyste mohli využívat nejnovější funkce, aktualizace zabezpečení a technickou podporu.
Table.Pivot(table as table, pivotValues as list, attributeColumn as text, valueColumn as text, optional aggregationFunction as nullable function) as table
Při dané dvojici sloupců, které představují páry atribut-hodnota, převádí data ze sloupce atributu do záhlaví sloupců.
Vezměte hodnoty "a", "b" a "c" ve sloupci atributu tabulky ({ [ 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 přetáhnejte je do vlastního sloupce.
využití
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"
)
výstupní
Table.FromRecords({
[key = "x", a = 1, b = null, c = 3],
[key = "y", a = 2, b = 4, c = null]
})
Vezměte hodnoty "a", "b" a "c" ve sloupci atributu tabulky ({ [ key = "x", attribute = "a", value = 1 ], [ key = "x", attribute = "c", value = 3 ], [ key = "x", attribute = "c", value = 5 ], [ key = "y", attribute = "a", value = 2 ], [ key = "y", attribute = "b", value = 4 ] })
a přetáhnejte je do vlastního sloupce. Atribut "c" pro klíč "x" má přiřazených více hodnot, takže k vyřešení konfliktu použijte funkci List.Max.
Použití
Table.Pivot(
Table.FromRecords({
[key = "x", attribute = "a", value = 1],
[key = "x", attribute = "c", value = 3],
[key = "x", attribute = "c", value = 5],
[key = "y", attribute = "a", value = 2],
[key = "y", attribute = "b", value = 4]
}),
{"a", "b", "c"},
"attribute",
"value",
List.Max
)
výstupní
Table.FromRecords({
[key = "x", a = 1, b = null, c = 5],
[key = "y", a = 2, b = 4, c = null]
})
Školení
Modul
Transform data by implementing pivot, unpivot, rollup, and cube - Training
This content is a part of Transform data by implementing pivot, unpivot, rollup, and cube.
Dokumentace
Table.AddColumn - PowerQuery M
Learn more about: Table.AddColumn
Table.SelectRows - PowerQuery M
Learn more about: Table.SelectRows
Table.TransformColumns - PowerQuery M
Learn more about: Table.TransformColumns