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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Remove duplicates based off of max date value from another column

Hello,

 

I'd like to remove duplicates from the 'Key' column, keeping only the rows which are the max of the 'Date' column.  Suggestions?

Much obliged,

-Red


What I have:

col1col2col3KeyDate
asdf11111

2310-209-2

11/1/2019

gfdag2222310-209-212/1/2019
fdfd132310-210-211/2/2019
fdfa442310-210-212/25/2019


What I want:

col1col2col3KeyDate
gfdag2222310-209-212/1/2019
fdfa442310-210-212/25/2019

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

You can have following for each column Col1 , col2, col3

 

 

Measure = 
VAR _Key = MAX ( 'Table'[Key] )
VAR _date = CALCULATE ( MAX( 'Table'[Date] ), ALLSELECTED ( 'Table' ),  'Table'[Key] = _Key ) 
RETURN CALCULATE ( MAX ( 'Table'[col3] ), VALUES ( 'Table'[Key] ), 'Table'[Key] = _Key, 'Table'[Date] = _date )

 

Another way to use addcolumns and summarize and use the same max filters there

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
Adamtall
Resolver III
Resolver III

Hi,

 

You can do a Group by in PowerQuery.

Use Key and operation Max with your date column.

 

/Adam

 

v-easonf-msft
Community Support
Community Support

Hi , @Anonymous 

According to you description ,you can  follow these steps:

1.create calculate column in table:

Column = CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[Key]))

a.png 

 

2.create  calculate table:

Table copy = SELECTCOLUMNS(FILTER('Table','Table'[Column]='Table'[Date]),"col1",'Table'[col1],"col2",'Table'[col2],"col3",'Table'[col3],"Key",'Table'[Key],"Date",'Table'[Date])

b.png

Here is a sample I made:

URL: https://wicren-my.sharepoint.com/:u:/g/personal/michael_wicren_onmicrosoft_com/ETfpMdkq_uFGt63Ensazfj4BmRyzgtNDoy1n8nGl9jxi-A?e=BaMAnP

 

In  addition ,you can refer to related post:

URL: https://community.powerbi.com/t5/Desktop/Remove-duplicates-based-on-values/td-p/59148

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

You can have following for each column Col1 , col2, col3

 

 

Measure = 
VAR _Key = MAX ( 'Table'[Key] )
VAR _date = CALCULATE ( MAX( 'Table'[Date] ), ALLSELECTED ( 'Table' ),  'Table'[Key] = _Key ) 
RETURN CALCULATE ( MAX ( 'Table'[col3] ), VALUES ( 'Table'[Key] ), 'Table'[Key] = _Key, 'Table'[Date] = _date )

 

Another way to use addcolumns and summarize and use the same max filters there

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.