Skip to main content
cancel
Showing results for 
Search instead 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

Reply
k_sun
Frequent Visitor

Measures to calculate Ranking

I've below data set and need to identify the ranking of "Player" based on their "Score" average.

 

PlayersMaster

PlayerTeamType
Player1Team1Local
Player2Team1Overseas
Player3Team2Local
Player4Team2Local
Player5Team2Overseas

 

MatchScores

MatchPlayerScore
Match1Player125
Match1Player240
Match1Player384
Match1Player419
Match1Player543
Match2Player156
Match2Player236
Match2Player361
Match2Player458
Match2Player590
Match3Player126
Match2Player234
Match2Player331
Match2Player431
Match2Player556

 

  • Ther's a one to many relationship between PlayersMaster[Player] and MatchScores[Player].
  • I've slicers in dashboard for Match, Player & Team.

Please support me in developing below measures.

1. Dynamic Ranking of Players (Top3) based on Average score. (Filtered upon slicer values)

I was able to identify the ranking using below measure. In visual, I just filtered the Top 3 players using a filter. Is there any other better way to achieve this?

Rank = RANKX(ALLSELECTED('PlayersMaster'),CALCULATE(AVERAGE('MatchScores'[Score])),,ASC,Dense)

 

2. Overall Ranking of Player, irrespective of slicer values.

Expected Result

PlayerRankTypeTotal
Player51Overseas63
Player32Local58.67
Player23Overseas36.67
Player44Local36
Player15Local35.67

 

3. Overall Ranking of Player based on Type, irrespective of slicer values

Expected Result

PlayerRankTypeTotal
Player51Overseas63
Player31Local58.67
Player22Overseas36.67
Player42Local36
Player13Local35.67

 

Thanks in advance

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

RANK_Type = RANKX( ALLSELECTED( PlayersMaster[Player] ), [Total],,, DENSE )
Rank_Overall = 
RANKX(
    ALL( PlayersMaster[Player] ),
    CALCULATE( [Total], ALLEXCEPT( PlayersMaster, PlayersMaster[Player] ) ),
    ,
    ,
    DENSE
)

Screenshot 2021-10-17 061934.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

RANK_Type = RANKX( ALLSELECTED( PlayersMaster[Player] ), [Total],,, DENSE )
Rank_Overall = 
RANKX(
    ALL( PlayersMaster[Player] ),
    CALCULATE( [Total], ALLEXCEPT( PlayersMaster, PlayersMaster[Player] ) ),
    ,
    ,
    DENSE
)

Screenshot 2021-10-17 061934.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Thanks a lot @CNENFRNL for your reply. However, I'm not clear about the [Total] field that you've used for both measures.

In my expected results I've considered the Average Score for each player as the Total.   

Please explain. 

Thanks

CNENFRNL
Community Champion
Community Champion

Total = AVERAGE('MatchScores'[Score])

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors