多条数据并成一条后合并查询(Power Query)
问题:两表合并,其中一表有重复的数据需要事先求和或合并
let
源 = Excel.CurrentWorkbook(){[Name="表1"]}[Content],
合并查询 = Table.NestedJoin(源, {"订单号"}, 表2, {"订单号"}, "表2", JoinKind.LeftOuter),
展开 = Table.ExpandTableColumn(合并查询, "表2", {"发运数量", "发运成本", "运单号"}, {"发运数量", "发运成本", "运单号"}),
更改的类型 = Table.TransformColumnTypes(展开,{{"订单号", type text}, {"发票号", type text}, {"存货代码", Int64.Type}, {"数量", Int64.Type}, {"收入", Int64.Type}, {"发运数量", Int64.Type}, {"发运成本", Int64.Type}, {"运单号", type text}})
in
更改的类型
let
源 = Excel.CurrentWorkbook(){[Name="表2"]}[Content],
分组的行 = Table.Group(源, {"订单号"}, {{"发运数量", each List.Sum([数量])}, {"发运成本", each List.Sum([成本])}, {"运单号", each Text.Combine([运单号],"/")}})
in
分组的行