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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jribs
Helper I
Helper I

DAX: Remove Duplicates based on Max date of column from a Union table

For technical reasons and general difficulty dealing with SAP BW as a datasource, I have a table modeled as a DAX UNION statement that glues together about 10 tables. That resulting table has duplicates and I'd like to keep the one with the most recent date. In Power Query, it is a straight forward "Group By", but it is not obvious in DAX

 

How can I achieve keeping rows based on an ID and where the date = the Max Date of that ID in DAX?

 

 

jribs_1-1620412609946.png

 

jribs_0-1620412588129.png

 

The table:

jribs_2-1620412677942.png

 

1 ACCEPTED SOLUTION
lance_6
Helper II
Helper II

Within the advanced editor, sort by `TECO Date`, in your case descending order. Then click on the carrot in your id column and click on what I believe is just called remove duplicates

 

It wouldn't let me respond in thread, so:

 

 

That makes sense. 

I like the summarize function. You could try someting like this:

 

SUMMARIZE (
TableName,
TableName[Key],
"Date", MAX(TableName[TECO Date]),
"NextCol", TableName[NextCol]
)

 

View solution in original post

3 REPLIES 3
lance_6
Helper II
Helper II

Within the advanced editor, sort by `TECO Date`, in your case descending order. Then click on the carrot in your id column and click on what I believe is just called remove duplicates

 

It wouldn't let me respond in thread, so:

 

 

That makes sense. 

I like the summarize function. You could try someting like this:

 

SUMMARIZE (
TableName,
TableName[Key],
"Date", MAX(TableName[TECO Date]),
"NextCol", TableName[NextCol]
)

 

I ended up using GROUPBY(TableName, Key, MAXX(CURRENTGROUP(), 'TECO Date'), ....), but your answer is pretty much the same thing. Thank you for the diligent response

Can't do this. Each of the tables are separate in M/Power Query. The final table is made in DAX with a Union statement. Doing this would eliminate duplicates withing individual talbes bu tnot across all tables

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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