let
源 = Excel.CurrentWorkbook(){[Name="表1"]}[Content],
a = Table.UnpivotOtherColumns(源, {"日期", "单位"}, "t","n"),
b = Table.CombineColumns(a,{"日期","t"},each _{0}&(if Text.End(_{1},1)="量" then "量" else "收"),"m"),
c = Table.Pivot(b, List.Distinct(b[m]), "m", "n", List.Sum),
d = Table.Sort(c,each List.PositionOf(源[单位],[单位])),
e = Table.ReorderColumns(d,List.Combine(List.Transform(List.Sort(List.Distinct(源[日期]),
each Number.From(Text.Remove(_,"月"))),each {_&"量",_&"收"})))
in
e
C:\Users\PC01\Desktop\QQ图片20230915132348.png |