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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JamesBx
New Member

Ranking score by user over month

Hi All, another new user here.

 

As the title suggests I have this concept of a league table where we are trying to rank users by a score.

 

I have 3 tables, uVw_New_Journeys which relates to a users table through user id and a dimensional table that relates to a date field.

 

I'm trying to get a ranking based on the months selected by user and their score.  The following DAX I have scratched around at to see if I can get it working but I cannot:

Rank = RANKX(ALL('users'[Name]),CALCULATE(SUM(uVw_New_Jouneys[total_score])),,DESC,Dense)
From this, I can't even get just a straight ranking that then leads onto the second part of this.  The ranking gives some strange results, even for months that don't exist.
 
If these scores tie, we would like to then start taking into account additional columns, we call infractions, that will tie break these for instance:
 
NameRankScoreSpeeding
Test1198100
Test529090
Test339080
Test749070
Test258890
Test468688
Test678290

 

Any help would be greatly appreciated.

5 REPLIES 5
JamesBx
New Member

So turns out I was using the wrong column for the rankx, I also changed it to allselected for the user which has gotten me to the first hurdle.  After bashing my head for a little while on this, i guess I just needed a little break and to look at it again to fix these rather obvious issues.  Not sure how I go about adding in additional columns now though.

 

I am now at:

Rank = RANKX(ALLSELECTED('users'[Name]),CALCULATE(uVw_New_Jouneys[Weighted Score]),,DESC,Dense)
az38
Community Champion
Community Champion

Hi @JamesBx 

check this great article https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Thank you, so if im reading this correct, here they are using add function to add the values together, i have tried this, but its not quite correct as the two values could add up to more that a lower rank.  It almost needs to be a waterfall approach.  Is the divide by 10000 doing this function that is described as a "technique" in this article?  To quote:

"The additional code is line 10, which extends the <expression> using a technique that makes the result of each <expression> unique without upsetting the initial sort order."

Here is one way to write this measure using the sample data you provided.

 

RankUsers = RANKX(ALL(Users[Name]), CALCULATE(SUMX(Users, Users[Score]+Users[Speeding]/1000)),,DESC,Dense)
 
Here is what it returns in a table visual.
rank.png
If this solution works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.
Regards,
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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