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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
Anonymous
Not applicable

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors