Infinite opportunities?  Endless problems?  Limited resources?  Talk to us!
Operations
Consulting
Software
Consulting
Publishing and
Training
Applied
Solutions
Excel add-ins
and tutorials
Charts Excel and VBA
Case Studies
VBA
tutorials
PowerPoint
Add-Ins
Miscellenia
You are on the Home/Excel/Tutorials/Ranking page
About this site

What's new

Google
Web
This Site
 

 

Ranking

Excel's RANK function ranks a number within a given range of numbers.  The syntax is

RANK(number,ref,order)

Number   is the number whose rank you want to find.

Ref   is an array of, or a reference to, a list of numbers. Nonnumeric values in ref are ignored.

Order   is a number specifying how to rank number.

If order is 0 (zero) or omitted, Microsoft Excel ranks number as if ref were a list sorted in descending order.
If order is any nonzero value, Microsoft Excel ranks number as if ref were a list sorted in ascending order

As intended, RANK gives the same rank to duplicates and resumes ranking for subsequent numbers after leaving a gap.  For example, consider a scenario where numbers are ranked in descending order.  If the number 10 appears twice in a list with a rank of 5, the next number, say 9, would have a rank of 7.  Similarly, since 9 appears 3 times, the next number, 8, has a rank of 10.  The formula in C3: =RANK(B3,$B$3:$B$12)  Copy C3 as far down as there are data in column B.

 

There are instances when this result is not acceptable.  This page looks at three ways to modify the result of Excel's RANK function.

To simplify the formulas, create two names (Insert | Name > Define...)

The first refers to the original data range, the other to the adjacent cells containing the unmodified RANK formula.

DataRng =Sheet1!$B$3:$B$12
RankRng =OFFSET(DataRng,0,1)

 

Adjust a tie so that it reports the "middle" value.

In the first cell containing the rank, enter the formula

=RANK(B3,DataRng)+(COUNTIF(DataRng,B3)-1)/2

Copy as far down as there are data in DataRng

Note that the Excel help file recommends the more complex correction factor

=(COUNT(ref) + 1 � RANK(number, ref, 0) � RANK(number, ref, 1))/2

 

Use a tie breaker to create a unique rank

In the first cell containing a rank, enter the formula

=RANK(B3,DataRng)+COUNTIF($B$3:B3,B3)-1

Copy as far down as there are data in DataRng.

 

A variant of the tie break that assigns ranks in reverse order

In the first cell containing a rank, enter the formula

=RANK(B3,DataRng)+COUNTIF(DataRng,B3)-COUNTIF($B$3:B3,B3)

Copy as far down as there are data in DataRng.

Retain duplicate values but create continuous ranks, i.e., no breaks in the rank.

In the first cell containing a rank, enter the array formula1

=SUM(1/(IF(RankRng<C3,COUNTIF(RankRng,RankRng),9.999999999E+307)))+1

Copy as far down as there are data in DataRng.

 

Accomplish the same with the new IFERROR function introduced with Excel 2007.

In the first cell containing a rank, enter the array formula1

=SUM(IFERROR(1/COUNTIF(RankRng,IF(RankRng<C3,RankRng)),0))+1

Copy as far down as there are data in DataRng.

 

1 To enter an array formula complete data entry *not* with the ENTER key but the CTRL+SHIFT+ENTER combination.

References: See Chip Pearson's http://www.cpearson.com/excel/rank.htm

 

 

For custom technology solutions, operations consulting, or training contact web-underscore-contact@tushar-hyphen-mehta-dot-cee-oh-em.
By accessing any page or link on this web site other than this page, you agree to the terms and conditions.

Ads from amazon.com

[Optional] Survey (current rating of site: 3.7 out of 4)  If you will take a moment to provide your comments, it will help improve the site both for you, and for other visitors.

On a scale of 4 (just what I need)
to zero (totally useless)

How do you rate the information

on this page?

  on this site?

[Optional]

Your name
Your email address
Other comments
 
Monitor page
for changes
    
   it's private  

by ChangeDetection
A comment selected at random:

 

 

Copyright © 2000-2008 Tushar Mehta.
Send comments and suggestions about the web site to webmaster@tushar-hyphen-mehta-dot-cee-oh-em
Last edited April 13, 2008