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
mlovejoy
Helper I
Helper I

DAX (add column) identify the max date of grouping

Hello community,

 

My problematic is straight forward I need to add DAX column. I have cirteria x, y and z. I can identify duplicate with this formula:

Duplicates count =

var x= Criteria
return
COUNTROWS(FILTER(Table,criteria = x)) this give me the number of duplicates (grouping).

Then for every duplicates I need to put a 1 to the most recent date of the grouping and a 0 to the oldest.

Is that even possible to do in DAX add Column?

Screenshot 2022-12-16 at 15.28.23.png

 

Thanks for your help,

Mark Lovejoy

1 ACCEPTED SOLUTION
TomasAndersson
Solution Sage
Solution Sage

Hi!

You should be able to do something like this:

Most recent date = 
VAR __IsDuplicate = //Checks if row has a duplicate. If all rows has duplicates, this is not needed.
    If('Table'[Duplicates]>0,TRUE(),FALSE())
    
VAR __MaxDate =  //Finds the most recent (MAX()) date for current criteria
    CALCULATE(
        max('Table'[Date]),
        FILTER(all('Table'),'Table'[Criteria] = EARLIER('Table'[Criteria])
        )
    )
return
if(__IsDuplicate,   //If current row is a duplicate
    if('Table'[Date] = __MaxDate,  //And current row date is the most recent date for this criteria
        1, //return 1
        0  //else return 0
    ),
    0 else return 0
)

Hope this helps!

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @mlovejoy 

please try

Result =
MAXX (
CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Criteria] ) ),
'Table'[Date]
)

TomasAndersson
Solution Sage
Solution Sage

Hi!

You should be able to do something like this:

Most recent date = 
VAR __IsDuplicate = //Checks if row has a duplicate. If all rows has duplicates, this is not needed.
    If('Table'[Duplicates]>0,TRUE(),FALSE())
    
VAR __MaxDate =  //Finds the most recent (MAX()) date for current criteria
    CALCULATE(
        max('Table'[Date]),
        FILTER(all('Table'),'Table'[Criteria] = EARLIER('Table'[Criteria])
        )
    )
return
if(__IsDuplicate,   //If current row is a duplicate
    if('Table'[Date] = __MaxDate,  //And current row date is the most recent date for this criteria
        1, //return 1
        0  //else return 0
    ),
    0 else return 0
)

Hope this helps!

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.