Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
gigotomo
Frequent 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.

 

Capture.JPG

2 ACCEPTED SOLUTIONS
thedatahiker
Employee
Employee

@gigotomo 
Here is one way to do this

  1. Open Power Query Editor
  2. Duplicate this table in PowerQuery
  3. delete summary column from new table
  4. Right click on INC_Num and select Group by
  5. In Group By pop up box give New Column Name the value "Submit", set operation to "MAX", and select Submit under Column. Click OK
  6. Duplicate INC_Num & Submit columns
  7. Duplicate INC_num column & Submit column in current Table
  8. select both "Inc_num - Copy" & "Submit - Copy", right click, and select Merge Columns. 
  9. Click OK in Merge Column popup box
  10. Return to the original table and repeat steps 6 - 8
  11. Now you have a shared Key you can Merge Queries together. From the Original Table click on "Merge Queries" in the top Home Ribbon
  12. 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)
  13. That's it. This will have only grabbed the INC_Num with the last date.  

View solution in original post

Tahreem24
Super User
Super User

@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

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

6 REPLIES 6
IDoLogistics
Frequent Visitor

Hi All,

 

I know this has already been answered, but it looks like Pragmatic Works has a more simple soloution to the problem involving "Table.Buffer".

https://www.google.com/search?q=power+query+how+to+sort+by+newest+date+then+remove+older+duplicates&...

Tahreem24
Super User
Super User

@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

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Brilliant!!!

Super !!!

thedatahiker
Employee
Employee

@gigotomo 
Here is one way to do this

  1. Open Power Query Editor
  2. Duplicate this table in PowerQuery
  3. delete summary column from new table
  4. Right click on INC_Num and select Group by
  5. In Group By pop up box give New Column Name the value "Submit", set operation to "MAX", and select Submit under Column. Click OK
  6. Duplicate INC_Num & Submit columns
  7. Duplicate INC_num column & Submit column in current Table
  8. select both "Inc_num - Copy" & "Submit - Copy", right click, and select Merge Columns. 
  9. Click OK in Merge Column popup box
  10. Return to the original table and repeat steps 6 - 8
  11. Now you have a shared Key you can Merge Queries together. From the Original Table click on "Merge Queries" in the top Home Ribbon
  12. 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)
  13. That's it. This will have only grabbed the INC_Num with the last date.  

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

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors