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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
RockStarNomad
Frequent Visitor

How to use RankX in a column based on a measure

I have a data set of game logs for a basketball season. I  want to do a ranking for a statistic comparing all teams, but only up to the current date of that specific row. Since not every team plays every day, the current row should be the max date and it should rank based on the most recent value up to that date. I have a measure that does the correct calculation:

 

 

 

LatestTmDVP =
VAR thisdate =
    MAX ( [DATE] )
VAR maxdate =
    CALCULATE ( MAX ( [DATE] ), ALLSELECTED ( 'NBA-PLAYER-FEED'[DATE] ) )
VAR result =
    CALCULATE (
        MAX ( 'NBA-PLAYER-FEED'[TmDVPoToDt] ),
        'NBA-PLAYER-FEED'[DATE] = maxdate
    )
RETURN
    IF ( thisdate = maxdate, result )

 

 

 

 

If I put this in a report with a date slicer, I can see that it is working correctly:

RockStarNomad_0-1675544629860.png

 

So I need to get this measure into a column, with the max date set as the date of the current row, and then do a rank of teams based on that, but I just can't get the RankX syntax right for this. Appreciate any help!

1 ACCEPTED SOLUTION
RockStarNomad
Frequent Visitor

So I ended up just giving up on this. I'm nearly certain it could be done in a formula for a column, but I ended up just creating a new sheet that has every date and team, regardless if they play or not, and looks up the current day's value, and if there is none, the prior day's value, etc. etc. So I then have a table with the most recent values. Essentially it's just brute-forcing what surely could be more elegant, but it works

View solution in original post

3 REPLIES 3
RockStarNomad
Frequent Visitor

So I ended up just giving up on this. I'm nearly certain it could be done in a formula for a column, but I ended up just creating a new sheet that has every date and team, regardless if they play or not, and looks up the current day's value, and if there is none, the prior day's value, etc. etc. So I then have a table with the most recent values. Essentially it's just brute-forcing what surely could be more elegant, but it works

lbendlin
Super User
Super User

 

So I need to get this measure into a column

 

That is not something you can do in Power BI. Rethink your requirement, maybe you can achieve it with a different approach.

Thanks for the reply. I might have to go back to Excel if I can't do it in PowerBI. Could I use a function like CalculateTable that would do similar to what the report with the slicer does, allowing it to essentially do a rank based on the most recent value? Or what about creating some kind of table with every date and every team that would allow a lookup?

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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