是否有办法使用PowerQuery实现这种转换?
输入表:
<表类> 城市年月价值 tbody><<tr>伦敦 2016 1月19 2月20 317 4月202017 1月19 2月20 317 4月20 巴黎2016 1月19 2月20 317 4月202017 1月19 2月20 317 4月20 罗马2016 1月19 2月20 317 4月202017 1月19 2月20 317 4月20 表类>
下面是使用示例数据模式的一种蛮力方法:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8snPS8nPU9JRAqFYnWglIwNDMyDbKzGvNLGoEsgytASLA1luqUlFUEEjA5igb2JRcgZImTlMxLGgKDMHoQZooDlVDQxILMosHlIuDsrPTR06Do4FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"City Year" = _t, Month = _t, Value = _t]),
#"Added Custom" = Table.AddColumn(Source, "City", each if [Month] = "" then [City Year] else null, type text),
#"Filled Down" = Table.FillDown(#"Added Custom",{"City"}),
#"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Month] <> "")),
#"Replaced Value" = Table.ReplaceValue(#"Filtered Rows","",null,Replacer.ReplaceValue,{"City Year"}),
#"Filled Down1" = Table.FillDown(#"Replaced Value",{"City Year"}),
#"Inserted Merged Column" = Table.AddColumn(#"Filled Down1", "Month/Year", each Text.Combine({[Month], [City Year]}, " "), type text),
#"Removed Other Columns" = Table.SelectColumns(#"Inserted Merged Column",{"City", "Month/Year", "Value"})
in
#"Removed Other Columns"