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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors