cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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?

Announcements

#### Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors