是否有一种方法来组合月和年,并添加城市在单独的列转换使用PowerQuery?



是否有办法使用PowerQuery实现这种转换?

输入表:

<表类>城市年月价值tbody><<tr>伦敦20161月192月203174月2020171月192月203174月20巴黎20161月192月203174月2020171月192月203174月20罗马20161月192月203174月2020171月192月203174月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"

相关内容

最新更新