Forum Discussion
gigotomo
5 years agoFrequent Visitor
How to remove duplicates based on latest dates
I am trying to remove the duplicate "INC_NUM" and only the latest date (Submit) should remain alongwith its summary. How do i do it.
- 5 years ago
gigotomo
Here is one way to do this- Open Power Query Editor
- Duplicate this table in PowerQuery
- delete summary column from new table
- Right click on INC_Num and select Group by
- In Group By pop up box give New Column Name the value "Submit", set operation to "MAX", and select Submit under Column. Click OK
- Duplicate INC_Num & Submit columns
- Duplicate INC_num column & Submit column in current Table
- select both "Inc_num - Copy" & "Submit - Copy", right click, and select Merge Columns.
- Click OK in Merge Column popup box
- Return to the original table and repeat steps 6 - 8
- Now you have a shared Key you can Merge Queries together. From the Original Table click on "Merge Queries" in the top Home Ribbon
- The top query will be your Original Table and you need to select the new aggregated table as the second table. Then click on the merged column in each table as your join column. Under Join Kind select "Inner (Only matching rows)
- That's it. This will have only grabbed the INC_Num with the last date.
- 5 years ago
gigotomo ,
Please refer the below thread to achieve your need.
https://community.powerbi.com/t5/Desktop/Drop-duplicate-rows-retaining-latest-date/m-p/878537
thedatahiker
5 years agoMicrosoft Employee
gigotomo
Here is one way to do this
- Open Power Query Editor
- Duplicate this table in PowerQuery
- delete summary column from new table
- Right click on INC_Num and select Group by
- In Group By pop up box give New Column Name the value "Submit", set operation to "MAX", and select Submit under Column. Click OK
- Duplicate INC_Num & Submit columns
- Duplicate INC_num column & Submit column in current Table
- select both "Inc_num - Copy" & "Submit - Copy", right click, and select Merge Columns.
- Click OK in Merge Column popup box
- Return to the original table and repeat steps 6 - 8
- Now you have a shared Key you can Merge Queries together. From the Original Table click on "Merge Queries" in the top Home Ribbon
- The top query will be your Original Table and you need to select the new aggregated table as the second table. Then click on the merged column in each table as your join column. Under Join Kind select "Inner (Only matching rows)
- That's it. This will have only grabbed the INC_Num with the last date.
- Anonymous3 years agoNot applicable
Thanks for the post
Took me a while to get my head around it, but it once I got it, it is actually real simple and effective.
I found it helpful to convert the dates to numbers. My other challenge was that I had two date columns. A start date but a termination date that was blank so I had to create a new custom column and give the blank date todays date in order to merge the start and termination date to get the biggest value to group by.
Cheers