问题:两表比对,结果如下A10:E13中的显示,要求,不使用自定义的M函数,全部使用Power Query的内置功能。
let
源 = Table.NestedJoin(表1, {"单号"}, 表2, {"单号"}, "表2", JoinKind.FullOuter),
#"展开的“表2”" = Table.ExpandTableColumn(源, "表2", {"单号"}, {"表2.单号"}),
删除的列 = Table.RemoveColumns(#"展开的“表2”",{"WK1 进展"}),
已添加条件列 = Table.AddColumn(删除的列, "完整单号", each if [单号] = null then [表2.单号] else [单号]),
已添加条件列1 = Table.AddColumn(已添加条件列, "单号对比", each if [单号] = [表2.单号] then "重复" else if [单号] = null then "新增" else "完成"),
已添加条件列2 = Table.AddColumn(已添加条件列1, "WK1", each if [单号对比] = "新增" then "N" else "Y"),
已添加条件列3 = Table.AddColumn(已添加条件列2, "WK2", each if [单号对比] = "完成" then "N" else "Y"),
分组的行 = Table.Group(已添加条件列3, {"单号对比"}, {{"条数", each Table.RowCount(_), Int64.Type}, {"内容", each _, type table [单号=nullable text, 表2.单号=nullable text, 完整单号=text, 单号对比=text, WK1=text, WK2=text]}}),
#"展开的“内容”" = Table.ExpandTableColumn(分组的行, "内容", {"完整单号", "WK1", "WK2"}, {"完整单号", "WK1", "WK2"}),
已添加索引 = Table.AddIndexColumn(#"展开的“内容”", "索引", 0, 1, Int64.Type),
已透视列 = Table.Pivot(Table.TransformColumnTypes(已添加索引, {{"索引", type text}}, "zh-CN"), List.Distinct(Table.TransformColumnTypes(已添加索引, {{"索引", type text}}, "zh-CN")[索引]), "索引", "完整单号"),
替换的值 = Table.ReplaceValue(已透视列,null,"啊",Replacer.ReplaceValue,{"0", "1", "2", "3", "4", "5", "6", "7", "8"}),
合并的列 = Table.CombineColumns(替换的值,{"0", "1", "2", "3", "4", "5", "6", "7", "8"},Combiner.CombineTextByDelimiter("/", QuoteStyle.None),"备注"),
替换的值1 = Table.ReplaceValue(合并的列,"啊/","",Replacer.ReplaceText,{"备注"}),
替换的值2 = Table.ReplaceValue(替换的值1,"/啊","",Replacer.ReplaceText,{"备注"}),
重排序的列 = Table.ReorderColumns(替换的值2,{"单号对比", "WK1", "WK2", "条数", "备注"})
in
重排序的列
标签:Power,text,each,索引,添加,Table,WK1,Query,两表比 From: https://www.cnblogs.com/officeplayer/p/17398336.html