1 列在视觉中使用了两次
1 Column used twice in the visual
我有数据模型,其中 table 之一有以下列:
CharacteristicsID
Type
Value
...
1
Country
UK
...
1
SalesPerson
Peter
...
2
Country
US
...
2
SalesPerson
Mark
...
2
SalesPerson
John
...
我需要做的是创建以下枢轴 table:
数字来自另一个相关 table,但现在这并不重要。
我的问题是 Country 和 SalesPerson 都来自同一列。难道你没有一些聪明的想法如何解决它吗?我可以编辑所有级别的源数据。
提前致谢
可能的解决方案。
我的样本 excel:
添加索引列(转换选项卡):
Select“类型”列并使用“数据透视列”值作为值,具有高级选项(不聚合)
Select“国家”并向下填写:
最终结果:
let
Source = Excel.Workbook(File.Contents("C:\Users\YourUser\Downloads\pivot.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"CharacteristicsID", Int64.Type}, {"Type", type text}, {"Value", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
#"Pivoted Column" = Table.Pivot(#"Added Index", List.Distinct(#"Added Index"[Type]), "Type", "Value"),
#"Filled Down" = Table.FillDown(#"Pivoted Column",{"Country"})
in
#"Filled Down"
我有数据模型,其中 table 之一有以下列:
CharacteristicsID | Type | Value | ... |
---|---|---|---|
1 | Country | UK | ... |
1 | SalesPerson | Peter | ... |
2 | Country | US | ... |
2 | SalesPerson | Mark | ... |
2 | SalesPerson | John | ... |
我需要做的是创建以下枢轴 table:
数字来自另一个相关 table,但现在这并不重要。
我的问题是 Country 和 SalesPerson 都来自同一列。难道你没有一些聪明的想法如何解决它吗?我可以编辑所有级别的源数据。
提前致谢
可能的解决方案。 我的样本 excel:
添加索引列(转换选项卡):
Select“类型”列并使用“数据透视列”值作为值,具有高级选项(不聚合)
Select“国家”并向下填写:
最终结果:
let
Source = Excel.Workbook(File.Contents("C:\Users\YourUser\Downloads\pivot.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"CharacteristicsID", Int64.Type}, {"Type", type text}, {"Value", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
#"Pivoted Column" = Table.Pivot(#"Added Index", List.Distinct(#"Added Index"[Type]), "Type", "Value"),
#"Filled Down" = Table.FillDown(#"Pivoted Column",{"Country"})
in
#"Filled Down"