let
源 = Excel.CurrentWorkbook(),
订单 = Table.PromoteHeaders(源{[Name="订单"]}[Content]),
配置表 = Table.PromoteHeaders(源{[Name="配置表"]}[Content]),
自定义1 = Table.Distinct(Table.Group(配置表,"商品组合",{"分组",each _},0,(x,y)=>Number.From(y is text))),
自定义2 = Table.RenameColumns(Table.RemoveColumns(订单,{"单价","金额"}),{"数量","组合数量"}),
自定义3 = Table.TransformColumns(自定义2,{"商品",each Table.SelectRows(自定义1,(x)=>x[商品组合]=_)[分组]{0}}),
自定义4 = Table.ExpandTableColumn(自定义3,"商品",{"商品子目","数量","单价"},{"商品","子数量","单价"}),
自定义5 = List.Accumulate({"数量","金额"},自定义4,(x,y)=>Table.AddColumn(x,y,each if y="数量" then [子数量]*[组合数量] else [数量]*[单价])),
删除的列 = Table.RemoveColumns(自定义5,{"子数量", "组合数量"}),
重排序的列 = Table.ReorderColumns(删除的列,{"订单号", "日期", "商品", "数量", "单价","金额", "收货人", "收货地址", "省", "市", "区", "详细地址"}),
更改的类型 = Table.TransformColumnTypes(重排序的列,{{"日期", type date}})
in
更改的类型
|