理论上支持多指标
let
源 = Excel.CurrentWorkbook(){[Name="表1"]}[Content],
指标 = List.Distinct(List.Transform(List.Select(Table.ColumnNames(源),each Text.Contains(_,"年")),each Text.Split(_,"20"){0})),
期间 = List.Distinct(List.Transform(List.Select(Table.ColumnNames(源),each Text.Contains(_,"年")),each "20"&Text.Split(_,"20"){1})),
合并列 = List.Accumulate(期间,源,(x,y)=>Table.CombineColumns(x,List.Select(Table.ColumnNames(x),each Text.Contains(_,y)),each _,y)),
逆透视 = Table.UnpivotOtherColumns(合并列,List.FirstN(Table.ColumnNames(合并列),2),"报告期","b"),
拆分列 = Table.SplitColumn(逆透视,"b",each _,指标),
分组排序 = Table.Combine(Table.Group(Table.ReorderColumns(拆分列,{"报告期"}&List.RemoveItems(Table.ColumnNames(拆分列),{"报告期"})),"报告期",{"分组",each _})[分组])
in
分组排序 |