我的操作如下 这个可能更好理解
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"供应商", type text}, {"订单编号", type text}, {"产品型号", type text}, {"订单数量", Int64.Type}, {"PBM采购单价(RMB)", Int64.Type}, {"PBM采购金额(RMB)", Int64.Type}, {"下单时间", type date}, {"是否使用新外箱(Y/N)", type text}, {"收货数量", Int64.Type}, {"收货时间", type datetime}, {"送货单号", type text}, {"对账单号/发票号", type any}, {"发票金额", Int64.Type}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"收货时间", type datetime}}),
#"Sorted Rows" = Table.Sort(#"Changed Type1",{{"供应商", Order.Ascending}, {"产品型号", Order.Ascending}, {"收货时间", Order.Descending}}),
Group = Table.Group(#"Sorted Rows",{"供应商","产品型号"},{"T", each Table.AddIndexColumn(_,"Index",0)}),
#"Expanded T" = Table.ExpandTableColumn(Group, "T", {"PBM采购单价(RMB)", "收货时间", "Index"}, {"PBM采购单价(RMB)", "收货时间", "Index"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded T", each ([Index] = 0 or [Index] = 1 or [Index] = 2)),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Index"}),
#"Changed Type2" = Table.TransformColumnTypes(#"Removed Columns",{{"收货时间", type datetime}})
in
#"Changed Type2" |