如何在 power 查询中仅转置 table 的某些列?
How can I transpose only some columns of a table in power query?
我有一个 table 像这样的电源查询:
Date
Name
OutputType
Group1
Group2
Group3
...
01/10/2021
A
Type1
565
63521
651
...
01/10/2021
A
Type2
6546
6541
13286
...
01/10/2021
B
Type1
0
5
685
...
01/10/2021
B
Type2
564
0
65
...
...
...
...
...
...
...
...
我想做的是仅“转置”OutputType 和组 headers,这样我的所有组都在一列中,我的 OutputType 变成 headers。像这样:
Date
Name
GroupTypes
Type1
Type2
01/10/2021
A
Group1
541
984
01/10/2021
A
Group2
8971
6526
01/10/2021
B
Group3
321
98
01/10/2021
B
Group4
564
845
...
...
...
...
...
我尝试对列进行逆透视,但我只得到了部分结果,因为我的所有组类型都变成了单个列。但是我无法将我的 OutputType 值“转换”为 headers.
有人知道如何在 power 查询中实现这个吗?
对不起,如果我的问题不是那么清楚,我的英语不是最好的。
感谢您的帮助!
单击 select 日期、名称和输出类型
右键单击取消透视其他列
单击select“输出类型”列
转换 .. 数据透视列 ... 并选择值作为值列
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Date", "Name", "OutputType"}, "Attribute", "Value"),
#"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[OutputType]), "OutputType", "Value", List.Sum)
in #"Pivoted Column"
我有一个 table 像这样的电源查询:
Date | Name | OutputType | Group1 | Group2 | Group3 | ... |
---|---|---|---|---|---|---|
01/10/2021 | A | Type1 | 565 | 63521 | 651 | ... |
01/10/2021 | A | Type2 | 6546 | 6541 | 13286 | ... |
01/10/2021 | B | Type1 | 0 | 5 | 685 | ... |
01/10/2021 | B | Type2 | 564 | 0 | 65 | ... |
... | ... | ... | ... | ... | ... | ... |
我想做的是仅“转置”OutputType 和组 headers,这样我的所有组都在一列中,我的 OutputType 变成 headers。像这样:
Date | Name | GroupTypes | Type1 | Type2 |
---|---|---|---|---|
01/10/2021 | A | Group1 | 541 | 984 |
01/10/2021 | A | Group2 | 8971 | 6526 |
01/10/2021 | B | Group3 | 321 | 98 |
01/10/2021 | B | Group4 | 564 | 845 |
... | ... | ... | ... | ... |
我尝试对列进行逆透视,但我只得到了部分结果,因为我的所有组类型都变成了单个列。但是我无法将我的 OutputType 值“转换”为 headers.
有人知道如何在 power 查询中实现这个吗?
对不起,如果我的问题不是那么清楚,我的英语不是最好的。
感谢您的帮助!
单击 select 日期、名称和输出类型
右键单击取消透视其他列
单击select“输出类型”列
转换 .. 数据透视列 ... 并选择值作为值列
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Date", "Name", "OutputType"}, "Attribute", "Value"),
#"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[OutputType]), "OutputType", "Value", List.Sum)
in #"Pivoted Column"