cancel
Showing results for 
Search instead for 
Did you mean: 

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

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

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

Power BI Fabric Summit Carousel

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