メインコンテンツまでスキップ

Table.Unpivot

テーブル内の一連の列を属性/値のペアに変換します。

Syntax

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

Remarks

テーブルの一連の列を属性/値のペアに変換します。その際、各行の残りの値と結合します。

Examples

Example #1

テーブル <code>({[ key = "x", a = 1, b = null, c = 3 ], [ key = "y", a = 2, b = 4, c = null ]})</code> の列 "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"
)

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