cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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:

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
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

3 REPLIES 3
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

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.

Frequent Visitor

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?