Forum Discussion
JonasWesth
7 years agoFrequent Visitor
Identify rows with duplicate values
I am new with Power BI and DAX, and hope the community can help with this specific issue. The purpose is to identify potential duplicate invoices, which are registrered under a different invoice...
- Anonymous7 years ago
Look:
Here's the M code:
let Source = Invoices,
#"Merged Queries" = Table.NestedJoin(Source, {"Vendor", "Posting Date", "Amount"}, #"Invoices - Duplicate Invoice Marker", {"Vendor", "Posting Date", "Amount"}, "Invoices - Duplicate Invoice Marker", JoinKind.LeftOuter), #"Expanded Invoices - Duplicate Invoice Marker" = Table.ExpandTableColumn(#"Merged Queries", "Invoices - Duplicate Invoice Marker", {"Inv No"}, {"Inv No.1"}), #"Removed Columns" = Table.RemoveColumns(#"Expanded Invoices - Duplicate Invoice Marker",{"Inv No.1"}), #"Grouped Rows" = Table.Group(#"Removed Columns", {"Inv No", "Vendor", "Posting Date", "Amount"}, {{"Count", each Table.RowCount(_), type number}}), #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Has Dups", each if [Count] > 1 then "Yes" else "No"), #"Removed Columns2" = Table.RemoveColumns(#"Added Custom",{"Count"}) in #"Removed Columns2"Here are the table dependencies:
Best
Darek
Anonymous
7 years agoNot applicable
Look:
Here's the M code:
let
Source = Invoices,
#"Merged Queries" = Table.NestedJoin(Source, {"Vendor", "Posting Date", "Amount"}, #"Invoices - Duplicate Invoice Marker", {"Vendor", "Posting Date", "Amount"}, "Invoices - Duplicate Invoice Marker", JoinKind.LeftOuter),
#"Expanded Invoices - Duplicate Invoice Marker" = Table.ExpandTableColumn(#"Merged Queries", "Invoices - Duplicate Invoice Marker", {"Inv No"}, {"Inv No.1"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Invoices - Duplicate Invoice Marker",{"Inv No.1"}),
#"Grouped Rows" = Table.Group(#"Removed Columns", {"Inv No", "Vendor", "Posting Date", "Amount"}, {{"Count", each Table.RowCount(_), type number}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Has Dups", each if [Count] > 1 then "Yes" else "No"),
#"Removed Columns2" = Table.RemoveColumns(#"Added Custom",{"Count"})
in
#"Removed Columns2"Here are the table dependencies:
Best
Darek
JonasWesth
7 years agoFrequent Visitor
Hi Darek
Your solutions is elegant and brilliant. The final table clearly shows which have duplicates and are candidates as same invoices scanned twice!
Thanks for the detailed description, including conjuring up your own example dataset! It was easy to follow, and allowed me a huge leap in knowledge of fundamentals of PQ and M!
Much appreciated
Jonas