You are on page 1of 7

Ranking Functions in Excel

Excel Functions: Figure 1 summarizes the various ranking functions available in all
versions of Excel for a data set R. We describe each of these functions in more detail in
the rest of this webpage, plus we describe additional ranking functions that are only
available in Excel 2010/2013.

Figure 1 – Ranking functions in Excel

Observation: All these functions ignore any empty cells and cells with non-numeric
values.

MIN and MAX

Definition 1: MIN(R) = the smallest value in R and MAX(R) = the largest value in R

Example 1: For range R with data elements {4, 0, -1, 7, 5}

 MIN(R) = -1
 MAX(R) = 7

SMALL and LARGE

Definition 2: SMALL(n, R) = the nth smallest value in R and LARGE(n, R) = the nth
largest value in R. Here n can take on any value from 1 to the number of elements in R,
i.e. COUNT(R).

Example 2: For range R with data elements {4, 0, -1, 7, 5}

 LARGE(1, R) = 7, LARGE(2, R) = 5, LARGE(5, R) = -1


 SMALL(1, R) = -1, SMALL(2, R) = 0, LARGE(5, R) = 7

Observation:
 SMALL(n, R) = LARGE(COUNT(R) – n + 1, R)
 LARGE(n, R) = SMALL(COUNT(R) – n + 1, R)

RANK

Definition 3: RANK(c, R, d) = the rank of data element c in R. If d = 0 (or is omitted)


then the ranking is in decreasing order, i.e. a rank of 1 represents the largest data element
in R. If d ≠ 0 then the ranking is in increasing order and so a rank of 1 represents the
smallest element in R.

Example 3: For range R with data elements {4, 0, -1, 7, 5}

 RANK(7, R) = RANK(7, R, 0) = 1
 RANK(7, R, 1) = 5
 RANK(0, R) = RANK(0, R, 0) = 4
 RANK(0, R, 1) = 2

Observation:

 If SMALL(n, R) = c then RANK(c, R) = RANK(c, R, 0) = n


 If LARGE(n, R) = c then RANK(c, R, 1) = n
 RANK(c, R) + RANK(c, R, 1) = COUNT(R) + 1
 For any value c and d, 1 ≤ RANK(c, R, d) ≤ COUNT(R)

Observation: Excel’s RANK function does not take care of ties very well. E.g., if the
range R contains the values {1, 5, 5, 0, 8}, then RANK(5, R) = 2 because 5 is the 2 nd
highest ranking element in range R. But 5 is also the 3 rd highest ranking element in the
range, and so for many applications it is useful to consider the ranking to be 2.5, namely
the average of 2 and 3.

To correct for ties for any data element c in the range R, you can use the following
formula (see Built-in Excel Functions for a description of the COUNTIF function):

= RANK(c, R) + (COUNTIF(R, c) – 1) / 2

Excel 2010/2013 Function: Excel 2010/2013 address this issue by providing a new
function RANK.AVG which has the same arguments as RANK but returns the average of
equal ranks as described above. Excel 2010/2013 also provide the function RANK.EQ
which is equivalent to RANK.

Real Statistics Function: For Excel 2007 users the Real Statistics Resource Pack
provides the supplemental function RANK_AVG which is equivalent to RANK.AVG.

Example 4: Using the RANK.AVG or RANK_AVG functions find the ranks of the data
in range E17:E23 of Figure 2.
Figure 2 – Average ranking

The result is shown in column F of Figure 2. E.g. the average rank of 8 (cell E21 or E22)
is 1.5, as calculated using the formula =RANK_AVG(E21,E17:E23) as shown in cell F21
(or F22). If instead you want the ranking in the reverse order (where the lowest value gets
rank 1) then the results are shown in column G. This time using the formula
=RANK_AVG(E21,E17:E23,1) we see that the rank of 8 is 6.5 as shown in cell G21.

Excel Data Analysis Tool: In addition to the functions described above,


Excel also provides a Rank and Percentile data analysis tool. This
tool uses the Excel 2007 definitions of rank and percentile.

Example 5: Calculate the rank and percentile for the following data (using the Excel
2007 definitions of rank and percentile).

Figure 3 – Data for Rank and Percentile data analysis tool

For the above data, the tool generates the table in Figure 4.
Figure 4 – Output from Rank and Percentile data analysis tool

The table is sorted in rank order. Point indicates the index of the corresponding score in
the input data range. E.g. 93 is the 9 th data element in the input range, but is the largest
data element and so has rank 1.

PERCENTILE

Definition 4: For any percentage p (i.e. 0 ≤ p ≤ 1 or equivalently 0% ≤ p ≤ 100%),


PERCENTILE(R, p) = the element at the pth percentile This means that if
PERCENTILE(R, p) = c then p% of the data elements in R are less than c.

If p = k/(n–1) for some integer value k = 0, 1, 2, … n–1 where n = COUNT(R), then


PERCENTILE(R, p) = SMALL(R, k+1) = the k+1th element in R. If p is not a multiple
of 1/(n–1), then the PERCENTILE function performs a linear interpolation as described
in the examples below.

Example 6: For range R with data elements {4, 0, -1, 7, 5}, the 5 data elements in R
divide the range into 4 intervals of size 25%, i.e. 1/(5-1) = .25. Thus

 PERCENTILE(R, 0) = -1 (the smallest element in R)


 PERCENTILE(R, .25) = 0 (the second smallest element in R)
 PERCENTILE(R, .5) = 4 (the third smallest element in R)
 PERCENTILE(R, .75) = 5 (the fourth smallest element in R)
 PERCENTILE(R, 1) = 7 (the fifth smallest element in R)

For other values of p we need to interpolate. For example

 PERCENTILE(R, .8) = 5 + (7 – 5) * (0.8 – 0.75) / 0.25 = 5.4


 PERCENTILE(R, .303) = 0 + (4 – 0) * (0.303 – 0.25) / 0.25 = .85

Of course, Excel’s PERCENTILE function calculates all these values automatically


without you having to figure things out.

Excel 2010/2013 Function: Excel 2010/2013 introduce an alternative version of the


percentile function named PERCENTILE.EXC.

If n = COUNT(R), then for any integer k with 1 ≤ k ≤ n,

PERCENTILE.EXC(R, k/(n+1)) = SMALL(R, k), i.e. the kth smallest element in R

For 0 < p < 1, if p is not a multiple of 1/(n + 1),then PERCENTILE.EXC(R, p) is


calculated by taking a linear interpolation between the corresponding values in R. For p <
1/(n+1) and p > n/(n+1), no interpolation is possible, and so PERCENTILE.EXC(R, p)
returns an error.
Excel 2010/2013 also provide the new function PERCENTILE.INC which is equivalent
to PERCENTILE.

Example 7: Find the 0 – 100 percentiles in increments of 10% for the data in Figure 3
using both PERCENTILE (or PERCENTILE.INC) and PERCENTILE.EXC.

The result is shown in Figure 5. E.g. the score at the 60th percentile is 58 (cell Z10) using
the formula =PERCENTILE(B3:M3,Y10), while it is 59 (cell AC10) using the formula
=PERCENTILE.EXC(B3:M3,AB10).

Figure 5 – PERCENTILE vs. PERCENTILE.EXC

PERCENTRANK

Definition 5: PERCENTRANK(R, c) = the percentage of data elements below c. If


PERCENTRANK(R, c) = p then PERCENTILE(R, p) = c.

Example 8: For range R with data elements {4, 0, -1, 7, 5}

 PERCENTRANK(R, 5) = .75
 PERCENTRANK(R, 54) = .8

You can also add a 3rd argument which represents the number of significant figures in the
answer. Thus PERCENTRANK(R, .85, 5) = .30312

Excel 2010/2013 Function: Excel 2010/2013 introduce an alternative version of the


percent rank function named PERCENTRANK.EXC. This function is defined so that if
PERCENTRANK.EXC(R, c) = p then PERCENTILE.EXC(R, p) = c.

Excel 2010/2013 also provide the new function PERCENTRANK.INC which is


equivalent to PERCENTRANK.
Example 9: Repeat Example 5 using the PERCENTRANK (or PERCENTRANK.INC)
and PERCENTRANK.EXC functions.

The result is shown in Figure 6. E.g. the score 45 (cell T12) is at the 27.2 th percentile (cell
V12) using the formula =PERCENTRANK(T4:T15,T12), while it is at the 30.7 th
percentile (cell W12) using the formula =PERCENTRANK.EXC(T4:T15,T12).

Figure 6 – PERCENTRANK vs. PERCENTRANK.EXC

QUARTILE

Definition 6: For any integer n = 0, 1, 2, 3 or 4, QUARTILE(R, n) = PERCENTILE(R,


n/4). If c is not an integer, but 0 ≤ c ≤ 4, then QUARTILE(R, c) = QUARTILE(R,
INT(c)).

Observation:

 QUARTILE(R, 0) = PERCENTILE(R, 0) = MIN(R)


 QUARTILE(R, 1) = PERCENTILE(R, .25)
 QUARTILE(R, 2) = PERCENTILE(R, .5) = MEDIAN(R)
 QUARTILE(R, 3) = PERCENTILE(R, .75)
 QUARTILE(R, 4) = PERCENTILE(R, 1) = MAX(R)

Example 10: For range R with data elements {4, 0, -1, 7, 5}

 QUARTILE(R, 0) = PERCENTILE(R, 0) = -1
 QUARTILE(R, 1) = PERCENTILE(R, .25) = 0
 QUARTILE(R, 2) = PERCENTILE(R, .5) = 4
 QUARTILE(R, 3) = PERCENTILE(R, .75) = 5
 QUARTILE(R, 4) = PERCENTILE(R, 1) = 7
Excel 2010/2013 Function: Excel 2010/2013 introduce an alternative version of the
quartile function named QUARTILE.EXC. This function is defined so that
QUARTILE.EXC(R, n) = PERCENTILE.EXC(R, n/4).

Excel 2010/2013 also provide the new function QUARTILE.INC which is equivalent to
QUARTILE.

One Response to Ranking Functions in Excel

1. David says:

March 28, 2014 at 1:45 pm

It’s all Greek to me. =.= Allthoug I am interested in this theme. I think I have to
deal a little more closely and intensively to that. So far I am often on tis website to
come closer to my destination, namely to understand excel: http://www.excel-
aid.com/the-excelrank-eq-function.html

Reply

You might also like