Excel RANK by Group: Overall and Group Rankings with COUNTIFS

Excel RANK by Group: A Recipe for Overall and Group Rankings with COUNTIFS

If your report needs both overall rankings and group (partial) rankings, the most reliable approach is to calculate overall rankings with RANK.EQ / RANK.AVG and create rankings within each group by counting comparisons with COUNTIFS. See the official Microsoft definitions as well.

Quick Fix — One-Line Group Ranking

=COUNTIFS($B:$B,B2, $D:$D, ">" & D2) + 1

RANK.EQ vs. RANK.AVG

  • RANK.EQ: Ties receive the same rank, and the next rank is skipped.
  • RANK.AVG: Ties receive the average rank.
  • order: 0 or omitted = descending order; 1 = ascending order.

Overall Ranking

=RANK.EQ(D2, $D:$D, 0)
=RANK.EQ(D2, $D:$D, 1)

Ranking by Group (Example: DIV)

=COUNTIFS($B:$B,B2, $D:$D, ">"&D2) + 1
=COUNTIFS($B:$B,B2, $D:$D, "<"&D2) + 1

Tie Breaker (Score > Date > Name)

=LET(grp,$B:$B, sc,$D:$D, dt,$C:$C, nm,$A:$A,
COUNTIFS(grp,B2, sc, ">"&D2)
+COUNTIFS(grp,B2, sc, D2, dt, ">"&C2)
+COUNTIFS(grp,B2, sc, D2, dt, C2, nm, "<"&A2) + 1)

Combine with Dynamic Arrays

=LET(u,UNIQUE(B2:B1000),
MAP(u,LAMBDA(d, TAKE(SORTBY(FILTER(A2:D1000, B2:B1000=d), D2:D1000, -1), 3))))

Troubleshooting

IssueCauseSolution
Rank is 0 or negativeOperator or text concatenation errorCheck the “>”&cell format.
Unexpected tie handlingConfusing RANK.EQ and RANK.AVGUse RANK.AVG for average ranks.
Group rankings are mixed upCOUNTIFS ranges have different lengthsMake all criteria ranges the same length.
Date comparison errorDates stored as textConvert with DATE or to numbers before comparing.
Slow performanceExcessive full-column referencesUse a Table and structured references.

Related Posts


References: Microsoft Support — RANK.EQ, RANK, RANK.AVG, COUNTIFS

Leave a Reply

Your email address will not be published. Required fields are marked *