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
Peter_
Resolver I
Resolver I

Filter on Date Rank Measure

Hi,

 

I'm trying to create measures which give me 1st, 2nd, 3rd date labels from the latest available date going back and it should depend on dates selected in a date range slicer. This works for the 1st label, i.e. when a date rank below is 1, but not for the others. Is there anything obviously wrong with the DAX expressions I'm using?

 

Date Rank measure

Date Rank =
RANKX( ALLSELECTED(Table[Aggregation Date]), CALCULATE(MAX(Table[Aggregation Date])), , DESC)
 
Date Label measures
[Date[Rank 1]] Label] = "as of " & UNICHAR(10) & CALCULATE(MAX(Table[Aggregation Date]), FILTER(Table, Table[Date Rank] = 1))
[Date[Rank 2]] Label] = "as of " & UNICHAR(10) & CALCULATE(MAX(Table[Aggregation Date]), FILTER(Table, Table[Date Rank] = 2))
 
Putting this into I table where there are two dates {11/17, 11/20} I get following:
 
 image.png
Setting the end of slicer to exclude 11/20, Date[Rank 1] Label updates to 11/17 as expected
 
image.png
 
 
1 ACCEPTED SOLUTION
Peter_
Resolver I
Resolver I

With a help from http://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures and experimentation via CONCATENATEX to see what values are being passed through the Calculate wasn't the way to go to implement this. Following measure does what I want:

[Date[Rank 1]] Label] = "as of " & UNICHAR(10) & FILTER(ALLSELECTED(Table[Aggregation Date]), [Date Rank] = 1)

View solution in original post

1 REPLY 1
Peter_
Resolver I
Resolver I

With a help from http://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures and experimentation via CONCATENATEX to see what values are being passed through the Calculate wasn't the way to go to implement this. Following measure does what I want:

[Date[Rank 1]] Label] = "as of " & UNICHAR(10) & FILTER(ALLSELECTED(Table[Aggregation Date]), [Date Rank] = 1)

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.