Skip to main content

Rank Function



How to Use the RANK Function

If you give the RANK function a number, and a list of numbers, it will tell you the rank of that number in the list, either in ascending or descending order.

For example, in the screen shot below, there is a list of 10 student test scores, in cells B2:B11.

To find the rank of the the first student's score in cell B2, enter this formula in cell C2:

=RANK(B2,$B$2:$B$11)

rank function 02

Then, copy the formula from cell C2 down to cell C11, and the scores will be ranked in descending order.

rank function 01

go to top

RANK Function Arguments

There are 3 arguments for the RANK function:

  • number: in the above example, the number to rank is in cell B2
  • ref: We want to compare the number to the list of numbers in cells $B$2:$B$11. Use an absolute reference ($B$2:$B11), instead of a relative reference (B2:B11)so the referenced range will stay the same when you copy the formula down to the cells below
  • order: (optional) This argument tells Excel whether to rank the list in ascending or descending order.
    • Use zero, or leave this argument empty, to find the rank in the list in descending order. In the example above, the order argument was left blank, to find the rank in descending order.
      =RANK(B2,$B$2:$B$11)
    • For ascending order, type a 1, or any other number except zero.
      If you were comparing golf scores, you could type a 1, to rank in ascending order.
      =RANK(B2,$B$2:$B$11,1)

go to top

RANK Function Order

In the RANK function, the 3rd argument (order), is optional. The order argument tells Excel whether to rank the list in ascending or descending order.

Order for RANK function

Descending Order

If you use a zero as the setting for order, or if you don't use the 3rd argument, the rank is set in descending order.

  • The largest number gets a rank of 1
  • The 5th largest number gets a rank of 5.

Order for RANK function

Ascending Order

If you use a 1 as the setting for order, or if you enter any number except zero as the 3rd argument, the rank is set in ascending order.

  • The smallest number gets a rank of 1
  • The 5th smallest number gets a rank of 5.

Order for RANK function

Flexible Formula

Instead of typing the order argument number into a RANK formula, use a cell reference, to create a flexible formula.

For example, type a 1 in cell E1, and link to cell E1 for the order argument.

NOTE: Be sure to use an absolute reference ($E$1), if the formula will be copied down to other rows. If you use a relative reference (E1), the reference will change in each row.

=RANK(B2,$B$2:$B$6,$E$1)

Order for RANK function

By linking to a cell, you can quickly see different results, without changing the formula. Type a zero in cell E1, or delete the number, and the rank will change to Descending order.

Order for RANK function

Comments

Popular posts from this blog

Up and Down Markers using Conditional Formatting

There is a super-obscure way to add up/down markers to a pivot table to indicate an increase or a decrease. Somewhere outside the pivot table, add columns to show increases or decreases. In the figure below, the difference between I6 and H6 is 3, but you just want to record this as a positive change. Use  SIGN(I6-H6)  to get either +1, 0, or -1. Select the two-column range showing the sign of the change and then select Home, Conditional Formatting, Icon Sets, 3 Triangles. (I have no idea why Microsoft called this option 3 Triangles, when it is clearly 2 Triangles and a Dash, as shown below.) With the same range selected, now select Home, Conditional Formatting, Manage Rules, Edit Rule. Check the Show Icon Only checkbox. With the same range selected, press  Ctrl+C  to copy. Select the first Tuesday cell in the pivot table. From the Home tab, open the Paste dropdown and choose Linked Picture. Excel pastes a live picture of the icons above the table. At this point, adju...

Indirect Function

INDIRECT  is pretty cool for grabbing a value from a cell. Can  INDIRECT  point to a multi-cell range and be used in a  VLOOKUP  or  SUMIF  function?  You can build an  INDIRECT  function that points to a range. The range might be used as the lookup table in a  VLOOKUP  or as a range in  SUMIF  or  COUNTIF . In  Figure , the formula pulls data from the worksheets specified in row 4. The second argument in the  SUMIF  function looks for records that match a certain date from column A. Note:  Because each worksheet might have a different number of records, I chose to have each range extend to 300. This is a number that is sufficiently larger than the number of transactions on any sheet. The formula in cell B5 is: =SUMIF(INDIRECT(B$4&"!A2:A300"), $A5, INDIRECT(B$4&"!C2:C300")) Summary:  You can use  INDIRECT  to grab data from a multi-cell range.

Create Sum that gives summary of all Worksheets in Excel

  You have a workbook with 12 worksheets, 1 for each month. All of the worksheets have the same number of rows and columns. You want a summary worksheet in order to total January through December. To create it, use the formula  =SUM(January:December!B4) . Copy the formula to all cells and you will have a summary of the other 12 worksheets. Caution I make sure to never put spaces in my worksheet names. If you do use spaces, the formula would have to include apostrophes, like this:  =SUM('Jan 2018:Mar 2018'!B4) .