Table.Unpivot
語法
Table.Unpivot(table as table, pivotColumns as list, attributeColumn as text, valueColumn as text) as table
關於
將資料表中的一組資料行轉譯為屬性/值組,並結合每個資料列中其餘的值。
範例 1
採用資料表 ({[ key = "x", a = 1, b = null, c = 3 ], [ key = "y", a = 2, b = 4, c = null ]})
中的資料行 "a"、"b" 和 "c",並將其取消樞紐分析成屬性/值組。
使用方式
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"
)
輸出
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]
})