Excel 删除Power Query中的重复项而不删除整行

Excel 删除Power Query中的重复项而不删除整行,excel,duplicates,powerquery,Excel,Duplicates,Powerquery,我需要删除多列中的重复项,而不删除整行。我有一个包含多个列的查询,有6个列需要从中删除重复项。列标题为: 未铸造订单 预测订单 预测和未预测 未结订单 能力 实际 我之前应用的步骤是重新排序列2。 这个的M代码是什么?提前谢谢 我无法按分组,因为每个预测日期都是针对给定月份的,并且该月份对应于预测中的多个月份。如果我无法在不删除整行的情况下删除这些重复项,有没有办法将重复项替换为null或将其置为空?谢谢。如果您想删除指定列中的所有重复项,无论剩余的[产品、预测日期、预测中的月份、属性]列中的值

我需要删除多列中的重复项,而不删除整行。我有一个包含多个列的查询,有6个列需要从中删除重复项。列标题为:

未铸造订单 预测订单 预测和未预测 未结订单 能力 实际

我之前应用的步骤是重新排序列2。 这个的M代码是什么?提前谢谢


我无法按分组,因为每个预测日期都是针对给定月份的,并且该月份对应于预测中的多个月份。如果我无法在不删除整行的情况下删除这些重复项,有没有办法将重复项替换为null或将其置为空?谢谢。

如果您想删除指定列中的所有重复项,无论剩余的[产品、预测日期、预测中的月份、属性]列中的值是什么,请使用

#"Added Index" = Table.AddIndexColumn(#"Reordered Columns2", "Index", 0, 1),
#"Removed Other Columns" = Table.SelectColumns(#"Added Index",{"Product", "Forecast Date", "Month in Forecast", "Attribute", "Index"}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Removed Other Columns", {"Index"}, "Attribute.1", "Value"),
#"Removed Columns" = Table.RemoveColumns(#"Added Index",{"Product", "Forecast Date", "Month in Forecast", "Attribute"}),
#"Unpivoted Other Columns2" = Table.UnpivotOtherColumns(#"Removed Columns", {"Index"}, "Attribute.1", "Value"),
#"Removed Duplicates" = Table.Distinct(#"Unpivoted Other Columns2", {"Attribute.1", "Value"}),
Combined = #"Unpivoted Other Columns" & #"Removed Duplicates",
#"Pivoted Column" = Table.Pivot(Combined, List.Distinct(Combined[Attribute.1]), "Attribute.1", "Value"),
#"Removed Columns1" = Table.RemoveColumns(#"Pivoted Column",{"Index"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns1",{{"Forecast Date", type date}, {"Month in Forecast", type date}})
in #"Changed Type1"

如果要根据第一次按[产品、预测日期、预测中的月份、属性]分组删除指定列中的所有重复项,请使用

#"Added Index" = Table.AddIndexColumn(#"Reordered Columns2", "Index", 0, 1),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Product", "Forecast Date", "Month in Forecast", "Attribute","Index"}, "Attribute.1", "Value"),
#"Removed Duplicates1" = Table.Distinct(#"Unpivoted Other Columns", {"Product", "Forecast Date", "Month in Forecast", "Attribute", "Attribute.1", "Value"}),
#"Pivoted Column" = Table.Pivot(#"Removed Duplicates1", List.Distinct(#"Removed Duplicates1"[Attribute.1]), "Attribute.1", "Value", List.Sum),
#"Sorted Rows" = Table.Sort(#"Pivoted Column",{{"Index", Order.Ascending}}),
#"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Index"})
in #"Removed Columns"

请在数据前后张贴样本。在表格数据中,不可能不删除整行。@Nick.McDermaid我将附上一张照片。不管产品、预测日期、预测或属性列中的月份值是多少?我们应该完全忽略这些列,并从指定的列中删除重复项?或者我们只是根据其他列的分组删除重复项?@horseyride您是对的,预测或属性列中的产品、预测日期、月份的值并不重要,因为存在重复项,我希望这些重复项保留下来。您好@horseyride感谢您的回复。我尝试了您与我共享的第二个选项,因为我正在尝试删除指定列中的所有重复项,这是基于按产品、预测日期、预测中的月份、属性进行的第一次分组,尽管它没有完成我尝试实现的输出。当我添加索引列时,我可以看到我的数据不包含任何多个索引。也许这意味着没有任何真正的复制品?如果是这种情况,是否有办法将重复项替换为null或0,而不是删除重复项?谢谢您的帮助。如果没有重复的,您将如何更换?