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
ontario234
Helper I
Helper I

RANKX with groups

Need some regarding the Rankx function. I need to assign ranks to the candidates on their average scores grouped by their group_Name. I tried the following and recieveing an error:

 

Rank = rankx(allexcept(Example_Rank,Example_Rank[Group_Name]),Example_Rank[Average_scores])

ERROR: A circular dependency was detected: Example_Rank[Rank].

 

The following is the output with field "RANK"  I am looking for:

 

Group_NameStudent_IDAverage_scoresRank
Group 11003.931
Group 11193.962
Group 11024.013
Group 11014.134
Group 11144.385
Group 21063.751
Group 21043.852
Group 21173.943
Group 21153.954
Group 21033.965
Group 21054.366
Group 31163.871
Group 31203.902
Group 31073.963
Group 31083.974
Group 31093.974
Group 41183.781
Group 41123.902
Group 41103.943
Group 41114.054
Group 41134.085
1 ACCEPTED SOLUTION

Sorry! My bad! Its working the way it should..the problem was fixed by fixing the decimal points of average grades to 2 digits..Thank you so much again!

View solution in original post

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

Hi @ontario234

 

Try this instead

 

RANK =
RANKX (
    FILTER (
        Example_Rank,
        Example_Rank[Group_Name] = EARLIER ( Example_Rank[Group_Name] )
    ),
    Example_Rank[Average_scores],
    ,
    ASC,
    DENSE
)

Regards
Zubair

Please try my custom visuals

i am unable to select, getting red underline

= EARLIER ( Example_Rank[Group_Name] )

Thank you Zubair. It worked however, i need to assign same rank when the average scores are same. For example; if there are two canidates with a score of 4.15, both of them should be assigned same rank instead of 2 consecutive ranks. Any suggestions on how to achieve that? Thanks

Sorry! My bad! Its working the way it should..the problem was fixed by fixing the decimal points of average grades to 2 digits..Thank you so much again!

I'm sorry for necroing this thread but when I try the proposed solution I get the error "EARLIER/EARLIEST refers to an earlier row contect which doesn't exist."

 

What creates the previous row context in your case but not mine? I have a plain table I try to rank by a grouping just the same way as in the example.

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.