본문으로 건너뛰기

Table.Pivot

특성-값 쌍을 나타내는 열 쌍이 지정된 경우 특성 열의 데이터를 열 머리글로 회전합니다.

Syntax

Table.Pivot(
table as table,
pivotValues as list,
attributeColumn as text,
valueColumn as text,
optional aggregationFunction as function
) as table

Remarks

특성-값 쌍을 나타내는 열 쌍이 지정된 경우 특성 열의 데이터를 열 머리글로 회전합니다.

Examples

Example #1

({ [ 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" 값을 고유한 열로 피벗합니다.

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"
)

Result:

Table.FromRecords({
[key = "x", a = 1, b = null, c = 3],
[key = "y", a = 2, b = 4, c = null]
})

Example #2

({ [ 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" 값을 고유한 열로 피벗합니다. "x" 키의 "c" 특성에는 서로 연결된 여러 값이 있으므로 충돌을 해결하려면 List.Max 함수를 사용합니다.

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
)

Result:

Table.FromRecords({
[key = "x", a = 1, b = null, c = 5],
[key = "y", a = 2, b = 4, c = null]
})

Category

Table.Column operations