Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to hide/remove duplicates based on condition

Hi, how do I hide/remove duplicate rows based on the following condition:

  • if [JobID+Ticket] column contains duplicate, keep row with the highest [Sequence] number and remove the other duplicate rows. Screenshot example below - keep Sequence "4676003" and delete the lower sequences above it

 

  • I'm guessing that it eliminated duplicates for each file individually but there were duplicates across files. I guess you do have to de-duplicate after combining the files then.

     

    In this case, you use the same code (with any step references adjusted, e.g. #"Merge Columns" --> #"Inserted Merged Column") but put it at the end of the FreightForward v2 query rather than the Transform Files (2) function.

     

    If you're going to use a database eventually, you might want to try approach #4 from my blog post.

14 Replies

  • Belin's avatar
    Belin
    Frequent Visitor

    As per my understanding the funcion "remove duplicates" works from top to bottom, so all you need to do is:

    - to append the new data to the old one (you will have now duplicates in your key column

    - sort them by the column you desire (for example if you need the most recent, sort it descending by update date, or If you need the highest sequence number, sort them in descending number). The important is that the record you want to keep is on a higher row than the one you want to remove

    - now right click on the key column and remove duplicates

     

    Sometimes the easiest solution is the best 🙂