Forum Discussion
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_Name | Student_ID | Average_scores | Rank |
| Group 1 | 100 | 3.93 | 1 |
| Group 1 | 119 | 3.96 | 2 |
| Group 1 | 102 | 4.01 | 3 |
| Group 1 | 101 | 4.13 | 4 |
| Group 1 | 114 | 4.38 | 5 |
| Group 2 | 106 | 3.75 | 1 |
| Group 2 | 104 | 3.85 | 2 |
| Group 2 | 117 | 3.94 | 3 |
| Group 2 | 115 | 3.95 | 4 |
| Group 2 | 103 | 3.96 | 5 |
| Group 2 | 105 | 4.36 | 6 |
| Group 3 | 116 | 3.87 | 1 |
| Group 3 | 120 | 3.90 | 2 |
| Group 3 | 107 | 3.96 | 3 |
| Group 3 | 108 | 3.97 | 4 |
| Group 3 | 109 | 3.97 | 4 |
| Group 4 | 118 | 3.78 | 1 |
| Group 4 | 112 | 3.90 | 2 |
| Group 4 | 110 | 3.94 | 3 |
| Group 4 | 111 | 4.05 | 4 |
| Group 4 | 113 | 4.08 | 5 |
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!
5 Replies
- Zubair_MuhammadCommunity 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 )- ontario234Helper I
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
- ontario234Helper I
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!
- spartanboyHelper II
i am unable to select, getting red underline
= EARLIER ( Example_Rank[Group_Name] )