答案 0 :(得分:1)
在加载到PowerQuery中之前,请在excelsheet中插入一行,并使用定界符将标题连接到value列中。如果使用office365,则可以使用TEXTJOIN函数执行此操作。结果看起来像这样(我没有复制所有数据):
将此表格导入PowerQuery并执行以下步骤:
unpivot columns
)脚本看起来像这样。
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type any}, {"Column5", type any}}),
#"Removed Top Rows" = Table.Skip(#"Changed Type",3),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Actual;jun;FY-2017", Int64.Type}, {"Actual;jul;FY-2017", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Column1", "Column2", "Column3"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), {"Attribute.1", "Attribute.2", "Attribute.3"}),
#"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}, {"Attribute.3", type text}})
in
#"Changed Type2"
结果: