Find Duplicate then filter on value

DavidG007

Board Regular
Joined
Jul 6, 2018
Messages
79
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I have a Power Query that works fine, however, I also have duplicate lines that I have also managed to flag as 'Duplicate', BUT, my problem is this;

So that I am able to filter, I need to flag just the one Duplicate line but it needs to flag the one that has the highest value in the column "Run Order"

Sounds simple but am really struggling, anyone have any idea's? anything would be really appreciated.

Account NumberSales CodeRun OrderDuplicate Check
12345ABC0DO NOT FLAG AS DUP
12345ABC100FLAG THIS LINE AS A DUP
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi David,

Try this:

1582147676270.png


Go to Transform > Group By > Advanced >
1582147748720.png


A new table will be now visible in your Queries. Go to Home > Merge Queries > make sure to select both "Account Number" and "Sales Code" columns when merging:
1582147800558.png


Now expand Table1B by only selecting Run Order Max column:
1582147870553.png


One last step - add a conditional column (Add Column > Custom Column):
Rich (BB code):
= Table.AddColumn(#"Expanded Table1B", "Custom", each if [Run Order]=[Table1B.Run Order Max] then [Run Order] else 0)

It will return max value or zero for each row. Feel free to change it to 1 and 0 if you want to flag each row.
1582147982555.png


Alternatively, here's DAX formula if you wish to create a new column straight in PowerBI app:

VBA Code:
cDuplicate = 
    IF([Run Order] <>
        CALCULATE(
            MAX(Table1[Run Order]),
            ALLEXCEPT(Table1, Table1[Account Number], Table1[Sales Code])
        ),
        0,
        [Run Order]
    )

1582148093071.png


Hope it helps!
 
Upvote 0
Hi Justyna,

Thank you very much for taking the time and effort with your reply, it was great, I followed each step and it has indeed solved my issue.

Thanks once again, really appreciated
 
Upvote 0

Forum statistics

Threads
1,223,806
Messages
6,174,725
Members
452,578
Latest member
Predaking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top