PQ解法
- let
- Source = Excel.CurrentWorkbook(){[Name="表1"]}[Content],
- #"Changed Type" = Table.TransformColumnTypes(Source,{{"上升编号", type text}, {"日期", Int64.Type}, {"大中小", type text}, {"数量", Int64.Type}}),
- #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"日期", type text}}, "zh-CN"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"日期", type text}}, "zh-CN")[日期]), "日期", "数量", List.Sum),
- Custom1 = Table.AddColumn(#"Pivoted Column","n",each Table.FromRows({Record.FieldValues(_)},List.ReplaceValue(Table.ColumnNames(#"Pivoted Column"),"大中小",[大中小],Replacer.ReplaceValue))),
- Custom2 = Table.Combine(Custom1[n]),
- Custom3 = Table.SelectColumns(Custom2,{"上升编号","大","中","小"}&List.Skip(Table.ColumnNames(#"Pivoted Column"),2))
- in
- Custom3
复制代码 |