Excel RANK functions with formula examples

The tutorial explains the specificities of the Excel Rank functions and shows how to do ranking in Excel based on multiple criteria, rank data by group, calculate percentile rank, and more.

When you need to determine the relative position of a number in a list of numbers, the easiest way is to sort the numbers in ascending or descending order. If for some reason sorting is not possible, a Rank formula in Excel is the perfect tool to do the job.

Excel RANK function

The RANK function in Excel returns the order (or rank) of a numeric value compared to other values in the same list. In other words, it tells you which value is the highest, the second highest, etc.

In a sorted list, the rank of a certain number would be its position. The RANK function in Excel can determine the rank starting with the largest value (as if sorted in descending order) or the smallest value (as if sorted in ascending order).

The syntax of the Excel RANK function is as follows:

RANK(number,ref,[order])

Where:

Number (required) - the value whose rank you'd like to find.

Ref (required) - a list of numeric values to rank against. It can be supplied as an array of numbers or a reference to the list of numbers.

Order (optional) - a number that specifies how to rank values:

  • If 0 or omitted, the values are ranked in descending order, i.e. from largest to smallest.
  • If 1 or any other non-zero value, the values are ranked in ascending order, i.e. from smallest to largest.

Excel RANK.EQ function

RANK.EQ is an improved version of the RANK function, introduced in Excel 2010. It has the same syntax as RANK and works with the same logic: if several values are ranked equally, the highest rank is assigned to all such values. (EQ stands for "equal").

RANK.EQ(number,ref,[order])

In Excel 2007 and lower versions, you should always use the RANK function. In Excel 2010, Excel 2013, and Excel 2016, you can go with either RANK or RANK.EQ. However, it'd be wise to use RANK.EQ because RANK can be discontinued at any moment.

Excel RANK.AVG function

RANK.AVG is another function to find rank in Excel that is available only in Excel 2010, Excel 2013, Excel 2016 and later.

It has the same syntax as the other two functions:

RANK.AVG(number,ref,[order])

The difference is that if more than one number has the same rank, the average rank is returned (AVG stands for "average").

4 things you should know about RANK in Excel

  1. Any Rank formula in Excel works only for numeric values: positive and negative numbers, zeros, date and time values. Non-numeric values in the ref argument are ignored.
  2. All RANK functions return the same rank for duplicate values, and skip subsequent ranking, as shown in the example below.
  3. In Excel 2010 and later versions, the RANK function has been replaced with RANK.EQ and RANK.AVG. For backward compatibility, RANK still works in all versions of Excel, but it may not be available in the future.
  4. If number is not found within ref, any Excel Rank function would return the #N/A error.

Basic Excel Rank formula (from highest to lowest)

To gain more understanding about ranking data in Excel, please have a look at this screenshot:
Rank formulas in Excel to rank numbers from highest to lowest

All three formulas rank numbers in column B in descending order (the order argument omitted):

In all versions of Excel 2003 - 2016:

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

In Excel 2010 - 2016:

=RANK.EQ($B2,$B$2:$B$7)

=RANK.AVG($B2,$B$2:$B$7)

The difference is in how these formulas process duplicate values. As you see, the same score appears twice, in cells B5 and B6, which affects subsequent ranking:

  • The RANK and RANK.EQ formulas give a rank of 2 to both duplicate scores. The next highest score (Daniela) is ranked 4th. A rank of 3 is not given to anyone.
  • The RANK.AVG formula assigns a different rank to each duplicate behind the scenes (2 and 3 in this example), and returns the average of those ranks (2.5). Again, the 3rd rank is not assigned to anyone.

How to use RANK in Excel - formula examples

The path to excellence, they say, is paved with practice. So, to better learn how to use RANK function in Excel, alone or in combination with other functions, let's work out solutions to a few real-life tasks.

How to rank in Excel from lowest to highest

As shown in the above example, to rank numbers from highest to lowest, you use one of the Excel Rank formulas with the order argument set to 0 or omitted (default).

To have number ranked against other numbers sorted in ascending order, put 1 or any other non-zero value in the optional third argument.

For example, to rank the 100-meter sprint times of the students, you can use either of the below formulas:

=RANK(B2,$B$2:$B$7,1)

=RANK.EQ(B2,$B$2:$B$7,1)

Please pay attention that we lock the range in the ref argument by using absolute cell references, so that it won't change when we copy the formula down the column.
Rank numbers from lowest to highest

As the result, the lowest value (fastest time) is ranked 1st and the largest value (slowest time) gets the lowest rank of 6. The equal times (B2 and B7) are given the same rank.

How to rank data in Excel uniquely

As pointed out earlier, all of the Excel Rank functions return the same rank for items of equal value. If that's not want you want, use one of the following formulas to resolve tie-break situations and give a unique rank to each number.

Unique ranking from highest to lowest

To rank the math scores of our students uniquely in descending order, use this formula:

=RANK.EQ(B2,$B$2:$B$7)+COUNTIF($B$2:B2,B2)-1
Unique ranking from highest to lowest

Unique ranking from lowest to highest

To rank the 100-meter race results in ascending order with no duplicates, use this formula:

=RANK.EQ(B2,$B$2:$B$7,1) + COUNTIF($B$2:B2,B2)-1
Unique ranking from lowest to highest

How these formulas work
As you may have noticed, the only difference between the two formulas is the order argument of the RANK.EQ function: omitted to rank values descending, 1 to rank ascending.

In both formulas, it's the COUNTIF function with the clever use of relative and absolute cell references that does the trick. In short, you use COUNTIF to find out how many occurrences of the number being ranked there are in the above cells, including the number's cell. In the topmost row where you enter the formula, the range consists of a single cell ($B$2:B2). But because you lock only the first reference ($B$2), the last relative reference (B2) changes based on the row where the formula is copied. Thus, for row 7, the range expands to $B$2:B7, and the value in B7 is compared to each of the above cells.

Consequently, for all 1st occurrences, COUNTIF returns 1; and you subtract 1 at the end of the formula to restore the original rank.

For 2nd occurrences, COUNTIF returns 2. By subtracting 1 you increment the rank by 1 point, thus preventing duplicates. If there happen to be 3 occurrences of the same value, COUNTIF()-1 would add 2 to their ranking, and so on.

Alternative solution to break Excel RANK ties

Another way to rank numbers in Excel uniquely is by adding up two COUNTIF functions:

  • The first function determines how many values are greater than or less than the number to be ranked, depending on whether you are ranking descending or ascending, respectively.
  • The second function (with the "expanding range" $B$2:B2 as in the above example) gets the number of values equal to the number.

For example, to rank numbers uniquely from highest to lowest, you'd use this formula:

=COUNTIF($B$2:$B$7,">"&$B2)+COUNTIF($B$2:B2,B2)

As shown in the screenshot below, the tie-break is successfully resolved, and a unique rank is assigned to each student:
Another way to break Excel RANK ties

Ranking in Excel based on multiple criteria

The previous example has demonstrated two working solutions for an Excel RANK tie break situation. However, it may seem unfair that equal numbers are ranked differently based solely on their position in the list. To improve your ranking, you may want to add one more criteria to be considered in case of a tie.

In our sample dataset, let's add total scores in column C and calculate rank as follows:

  • First, rank with Math Score (main criteria)
  • When there is a tie, break it with Total Score (secondary criteria)

To have it done, we will be using a regular RANK/RANK.EQ formula to find rank, and the COUNTIFS function to break a tie:

=RANK.EQ($B2,$B$2:$B$7) + COUNTIFS($B$2:$B$7, $B2, $C$2:$C$7, ">"& $C2)

Compared to the above example, this rank formula is more objective: Timothy is ranked 2nd because his total score is higher than that of Julia:
Ranking data based on multiple criteria

How this formula works

The RANK part of the formula is obvious, and the COUNTIFS function does the following:

  • The first criteria_range/criteria pair ($B$2:$B$7,$B2) counts the occurrences of the value you are ranking. Please notice, we fix the range with absolute references, but do not lock the criteria's row ($B2) so that the formula checks the value in each row individually.
  • The second criteria_range/criteria pair ($C$2:$C$7,">"&$C2) finds out how many total scores are greater than the total score of the value being ranked.

Because COUNTIFS works with the AND logic, i.e. counts only cells that meet all of the specified conditions, it returns 0 for Timothy since no other student with the same Math score has a higher total score. Hence, Timothy's rank returned by RANK.EQ is unchanged. For Julia, the COUNTIFS function returns 1 because one student with the same Math score has a higher total, so her rank number is incremented by 1. If one more student had the same Math score and a total score lower than that of Timothy and Julia, his/her rank would be incremented by 2, and so on.

Alternative solutions to rank numbers with multiple criteria

Instead of the RANK or RANK.EQ function, you could use COUNTIF to check the main criteria, and COUNTIFS or SUMPRODUCT to resolve a tie break:

=COUNTIF($B$2:$B$7,">"&$B2) + COUNTIFS($B$2:$B$7, $B2, $C$2:$C$7, ">"&$C2) + 1

=COUNTIF($B$2:$B$7, ">"&$B2) + SUMPRODUCT(--($B$2:$B$7=$B2), --($C$2:$C$7>$C2)) + 1

The result of these formulas are exactly the same as shown above.

How to calculate percentile rank in Excel

In statistics, a percentile (or centile) is the value below which a certain percentage of values in a given dataset falls. For example, if 70% of students are equal to or below your test score, your percentile rank is 70.

To get percentile rank in Excel, use the RANK or RANK.EQ function with a non-zero order argument to rank numbers from smallest to largest, and then divide the rank by the count of numbers. So, the generic Excel Percentile Rank formula goes as follows:

RANK.EQ(topmost_cell,range,1)/COUNT(range)

To calculate the percentile rank of our students, the formula takes the following shape:

=RANK.EQ(B2,$B$2:$B$7,1)/COUNT($B$2:$B$7)

To have the results displayed correctly, be sure to set the Percentage format to the formula cells:
Calculating percentile rank in Excel

How to rank numbers in non-adjacent cells

In situations when you need to rank non-contiguous cells, supply those cells directly in the ref argument of your Excel Rank formula in the form of a reference union, locking the references with the $ sign. For example:

=RANK(B2,($B$2,$B$4,$B$6))

To prevent errors in non-ranked cells, wrap RANK in the IFERROR function, like this:

=IFERROR(RANK(B2,($B$2,$B$4,$B$6)), "")

Please notice that a duplicate number is also given a rank, though cell B5 is not included in the formula:
Ranking numbers in non-adjacent cells

If you need to rank multiple non-contiguous cells, the above formula may become too long. In this case, a more elegant solution would be defining a named range, and referencing that name in the formula:

=IFERROR(RANK(B2,range), "")
Ranking numbers in non-contiguous cells based on a named range.

How to rank in Excel by group

When working with entries organized into some kind of data structure, data may belong to various groups, and you might want to rank numbers within each group individually. The Excel RANK function cannot resolve this challenge, so we are going to use a more complex SUMPRODUCT formula:

Rank by group in descending order:

=SUMPRODUCT((A2=$A$2:$A$7)*(C2<$C$2:$C$7))+1

Rank by group in ascending order:

=SUMPRODUCT((A2=$A$2:$A$7)*(C2>$C$2:$C$7))+1

Where:

  • A2:A7 are groups assigned to numbers.
  • C2:C7 are numbers to be ranked.

In this example, we use the first formula to rank numbers in each group from largest to smallest:
Ranking data by group

How this formula works
Essentially, the formula evaluates 2 conditions:

  • First, you check the group (A2=$A$2:$A$7). This part returns an array of TRUE and FALSE based on whether a range element belongs to the same group as A2.
  • Second, you check the score. To rank values from largest to smallest (descending order), use the condition (C2<$C$2:$C$11), which returns TRUE for the cells greater than or equal to C2, FALSE otherwise.

Since in Microsoft Excel terms, TRUE = 1 and FALSE = 0, multiplying the two arrays gives an array of 1's and 0's, where 1 is returned only for the rows in which both conditions are met.

Then, SUMPRODUCT adds up the elements of the 1's and 0's array, hence returning 0 for the largest number in each group. And you add 1 to the result to start ranking with 1.

The formula that ranks numbers within groups from smallest to largest (ascending order) works with the same logic. The difference is that SUMPRODUCT returns 0 for the smallest number in a particular group, since no number in that group meets the 2nd condition (C2>$C$2:$C$7). Again, you replace zero rank with the 1st rank by adding 1 to the formula result.

Instead of SUMPRODUCT, you can use the SUM function to add up the array elements. But this would require using an array formula, completed via Ctrl + Shift + Enter. For example:

=SUM((A2=$A$2:$A$7)*(C2<$C$2:$C$7))+1

How to rank positive and negative numbers separately

If your list of numbers contains both positive and negative values, the Excel RANK function will rank them all in no time. But what if you'd like to have positive and negative numbers ranked separately?

With numbers in cells A2 to A10, use one of the following formulas to get individual ranking for positive and negative values:

Rank positive numbers descending:

=IF($A2>0,COUNTIF($A$2:$A$10,">"&A2)+1,"")

Rank positive numbers ascending:

=IF($A2>0,COUNTIF($A$2:$A$10,">0")-COUNTIF($A$2:$A$10,">"&$A2),"")

Rank negative numbers descending:

=IF($A2<0,COUNTIF($A$2:$A$10,"<0")-COUNTIF($A$2:$A$10,"<"&$A2),"")

Rank negative numbers ascending:

=IF($A2<0,COUNTIF($A$2:$A$10,"<"&$A2)+1,"")

The results will look something similar to this:
Ranking positive and negative numbers separately

How these formulas work

To begin with, let's break down the formula that ranks positive numbers in descending order:

  • In the logical test of the IF function, you check whether the number is greater than zero.
  • If the number is greater than 0, the COUNTIF function returns the count of values higher than the number being ranked.

    In this example, A2 contains the 2nd highest positive number, for which COUNTIF returns 1, meaning there is just one number greater than it. In order to start our ranking with 1, not 0, we add 1 to the formula result, so it returns a rank of 2 for A2.

  • If the number is greater than 0, the formula returns an empty string ("").

The formula that ranks positive numbers in ascending order works a bit differently:

If the number is greater than 0, the first COUNTIF gets the total count of positive numbers in the data set, and the second COUNTIF finds out how many values are higher than that number. Then, you subtract the latter from the former, and get the desired rank. In this example, there are 5 positive values, 1 of which is greater than A2. So, you subtract 1 from 5, thus getting a rank of 4 for A2.

Formulas to rank negative numbers are based on a similar logic.

Note. All of the above formulas ignore zero values because 0 belongs neither to the set of positive nor to the set of negative numbers. To include zeros in your ranking, replace >0 and <0 with >=0 and <=0, respectively, where the formula logic requires.

For example, to rank positive numbers and zeros from largest to smallest, use this formula: =IF($A2>=0,COUNTIF($A$2:$A$10,">"&A2)+1,"")

How to rank data in Excel ignoring zero values

As you already know, a RANK formula is Excel handles all numbers: positive, negative and zeros. But in some cases, we just want to rank cells with data ignoring 0 values. On the web, you can find a few possible solutions for this task, but the Excel RANK IF formula, methinks, is the most universal one:

Rank numbers descending ignoring zero:

=IF($B2=0,"",IF($B2>0,RANK($B2,$B$2:$B$10), RANK($B2,$B$2:$B$10)-COUNTIF($B$2:$B$10,0)))

Rank numbers ascending ignoring zero:

=IF($B2=0,"",IF($B2>0,RANK($B2,$B$2:$B$10,1) - COUNTIF($B$2:$B$10,0), RANK($B2,$B$2:$B$10,1)))

Where B2:B10 is the range of numbers to be ranked.

The best thing about this formula is that it works beautifully both for positive and negative numbers, leaving zero values out of ranking:
Rank numbers in Excel ignoring zero values

How this formula works
At first sight, the formula may seem a bit tricky. Upon a closer look, the logic is very simple.

Here's how the Excel RANK IF formula ranks numbers from largest to smallest ignoring zeros:

  • The first IF checks whether the number is 0, and if it is, returns an empty string:

    IF($B2=0,"", …)

  • If the number is not zero, the second IF checks whether it's greater than 0, and if it is, a regular RANK / RANK.EQ function calculates its rank:

    IF($B2>0,RANK($B2,$B$2:$B$10),…)

  • If the number is less than 0, you adjust ranking by the zero count. In this example, there are 4 positive numbers and 2 zeros. So, for the largest negative number in B10, an Excel RANK formula would return 7. But we skip zeros, and therefore we need to adjust the rank by 2 points. For this, we subtract the number of zeros from the rank:

    RANK($B2,$B$2:$B$10)-COUNTIF($B$2:$B$10,0))

Yep, it's that easy! The formula to ranks numbers from smallest to largest ignoring zeroes works in a similar manner, and it could be a good brain exercise to deduce its logic :)

How to calculate rank in Excel by absolute value

When dealing with a list of positive and negative values, there may be a need to rank numbers by their absolute values ignoring the sign.

The task can be fulfilled with one of the bellow formulas, at the heart of which is the ABS function that returns the absolute value of a number:

Rank ABS descending:

=SUMPRODUCT((ABS(A2)<=ABS(A$2:A$7)) * (A$2:A$7<>"")) - SUMPRODUCT((ABS(A2)=ABS($A$2:$A$7)) * (A$2:A$7<>""))+1

Rank ABS ascending:

=SUMPRODUCT((ABS(A2)>=ABS(A$2:A$7)) * (A$2:A$7<>"")) - SUMPRODUCT((ABS(A2)=ABS($A$2:$A$7)) * (A$2:A$7<>""))+1

As the result, negative numbers are ranked as if they were positive numbers:
Find rank in Excel by absolute value

How to get N largest or smallest values

If you wish to get an actual N number of the largest or smallest values rather than their ranking, use the LARGE or SMALL function, respectively.

For example, we can get the top 3 scores of our students with this formula:

=LARGE($B$2:$B$7, $D3)

Where B2:B7 is the list of scores and D3 is the desired rank.

Additionally, you can retrieve the students' names by using the INDEX MATCH formula (provided there are no duplicate scores in the top 3):

=INDEX($A$2:$A$7,MATCH(E3,$B$2:$B$7,0))
Use the LARGE function to get the top 3 values in the list

Similarly, you can use the SMALL function to pull the bottom 3 values:

=SMALL($B$2:$B$7, $D3)
Use the SMALL function to get the bottom 3 values

That's how you do ranking in Excel. I thank you for reading and hope to see you on our blog next week!

Practice workbook for download

Rank formula in Excel - examples (.xlsx file)

155 comments

  1. Topic - How to get N largest or smallest values

    Student Score
    Daniela 79
    Tommy 79
    Edward 90
    Julia 88
    Timothy 89
    Peter 75

    Bottom 3
    Score Name
    1 75 Peter
    2 79 Daniela
    3 79 Daniela

    79 Score will be repeated name, it is not taking next name in Index Formula. How to correct it.

  2. Hi there,

    I have used the rank eq function to rank the number of stores as per their sales values. What I'm trying to do is allocate stock to these stores. I have applied the logic but there is remainder stock that I want to be able to allocate to the top 10 ranked stores. For example if I have 200 units left, I want to be able to allocate 10 out of this 200 to each of the top 10 stores in a loop. 1st store gets 10, then 2nd, then 3rd till the time 200 becomes zero. HELP!!

    Cheers

  3. Hi

    I am wondering if there is a formula I can use to show the ranking slightly differently to how this formula is working. In the example below, there are 18 records and ideally I would like the first three to show 18, then then the next two as 15, then the next three as 13 and so forth. The way it is working currently is that it is ordering up from 1, so if has four values as 1, then the next group as 5. So I am looking for similar logic, but having the ranking start from the higher numbers, not the lower numbers. If this is not clear, please let me know.

    Best result adjusted Sum Product Rank
    -0.95 16
    -0.95 16
    -0.95 16
    -0.9 14
    -0.9 14
    -0.85 11
    -0.85 11
    -0.85 11
    -0.8 8
    -0.8 8
    -0.8 8
    -0.75 5
    -0.75 5
    -0.75 5
    -0.7 1
    -0.7 1
    -0.7 1
    -0.7 1

    • Hello!
      Use the RANK.EQ function, a detailed description of which you can see in the article above.

      =RANK.EQ(A2,$A$2:$A$19,0)

      Сopy this formula down along the column.

  4. Hello - I am trying to rank race times and then ultimately give the ranked position a point value. For example there are 3 competitors with times: 12.8, 13.5, 10.1 and I want to rank them with 1st, 2nd, 3rd or 1,2,3; then give 1st = 10 pts, 2nd= 9 pts, 3rd = 8 pts. What formula would I use or how would I go about getting to the ultimate place of points? I made a column with the ranking using this formula I found: =IF($B4=0,"",IF($B4>0,RANK($B4,$B$4:$B$22,1) - COUNTIF($B$4:$B$22,0), RANK($B4,$B$4:$B$22,1)))

    But now I need to create the points associated with the rank. Thank you. Bella

  5. Hello friends. Please I want to rank my students whose individual records are contained in different sheets of same workbook and know who comes 1st, 2nd 3rd....etc. can't seem to solve it. Please help.

  6. I have positive and negative values for planet strength for 9 planets..I want Ranking considering both positive and negative values..
    Kethu 865 420
    Jupiter 1464 551
    Rahu 1389 666
    Mercury 1282 840
    Venus 923 385
    Sun 728 460
    Moon 1200 611
    Mars 1293 596
    Saturn 1406 556
    Rank is required..Kindly advise..

    • Hello!
      If I understand your task correctly, pay attention to the paragraph in this article - How to calculate rank in Excel by absolute value

  7. Hello, I tried to apply the formula which worked for rounded values but doesnt seem to work with others :

    It worked with this list :
    66
    94
    77
    99
    106
    82
    113
    75
    90
    96
    65
    95

    But not with these values :
    Turnover £1m

    20.5
    26.9
    4.6
    47.8
    9
    37.1
    19.8
    31.5
    28
    22.5
    28.9
    21.2
    19
    24.7
    38.9
    41.5
    14
    22.7
    28.9
    12.3

    Is there another formula? Cause it keeps on saying NO VALUE when I try to do the RANK.AVG formula
    Thank you very much

    • Hello!
      I cannot guess which formula you are using. If all of your values in the list are numbers, then the RANK.AVG function works correctly.

  8. i am facing a problem. problem is that i have a marks sheet of students in which mostly we have same mark of students. i need same position against of same marks and next highest position should be second but that shows third instead of 2nd.... need help

    • Hello!
      To determine the rank in a list with duplicate values, use the formula

      =RANK(A2,$A$2:$A$15,0)+COUNTIF(A$2:A2,A2)-1

      This should solve your task.

      • not working sir.... let me give you example

        obtain marks Perc% Rank expecting
        419 99.76 1 1
        419 99.76 1 1
        418.5 99.64 3 2
        418.5 99.64 3 2
        414 98.57 5 3

        i need rank as 1-1-2-2-3

        • Hi!
          To determine the rank in a list with duplicate values, use the formula:

          =COUNT(1/FREQUENCY($A$2:$A$15,IF($A$2:$A$15>=A2,$A$2:$A$15)))

          In Excel2019 and below, you must enter as an array formula.

  9. Hi,

    This is excellent thanks for sharing, is there a way to modify the option "How to calculate rank in Excel by absolute value" to be based on another criteria, e.g. rank absolute value by department (I have blanks in the data which need lowest value given and then the lowest actual number with a 2 etc)?

    Any guidance which would hugely appreciated

    BW
    Mark

      • Hi,

        Thanks for the resposne.

        I have tried this and my data has ties and blanks within it, using the option you suggested doesn't provide a dense rank unfortunately. It skips values when there is a tie.

        Is there a way of modifying it so a tie would return the same value, then the next would increment by 1 (with zero always being the lowest returned value as I'm raking in descending order)?

        Thanks I really appreciate your assistance

        BW
        Mark

        • Sorry I meant to state 1 as the lowest rank returned, which blanks should be allocated and then a 1 to the lowest number that isn't blank :-)

          • Hi!
            I could not find the problems you are talking about. The same results do not affect the ranking. The resulting ranks are, for example, 1, 1, and 3. Clarify your problem.

            • Thanks for coming back to me, I've tried two formulas to do this including your suggestion which is appreciated.

              Say I have a set up results as follows, what I need is for the rank not to skip a value in a tie situation (dense rank).

              So the top rows would read, 1, 2, 2, 3, 3, 4, 4 as opposed to 1, 2, 2, 4, 4, 6, 6

              race_id race_rpr RPR Rank2 RPR Rank 3
              788256 74 1 1
              788256 73 2 2
              788256 73 2 2
              788256 72 4 4
              788256 72 4 4
              788256 71 6 6
              788256 71 6 6
              788256 70 8 8
              788256 70 8 8
              788256 70 8 8
              788256 69 11 11
              788256 69 11 11
              788256 68 13 13
              788256 67 14 14
              788256 63 15 15

              Hopefully this makes sense, the fomulas I'm using are in a table, both are delivering the same result

              RPR Rank 1 =SUMPRODUCT(($B2=[race_id])*(W2"&[@[race_rpr]],[race_id],[@[race_id]])+1

              • Hello!
                To calculate the dense rating for a group, use the formula

                =SUMPRODUCT((FREQUENCY(IF($A$1:$A$15=A1,$B$1:$B$15),$B$1:$B$15)>0)*($B$1:$B$16>=B1))

                This is an array formula. Press Ctrl + Shift + Enter so that array function works.

              • Alexander, I was trying to repurpose your SUMPRODUCT((FREQUENCY piece for my application but I'm not quite getting what I'm after. I feel like arrays have always been my weakest area in Excel. Here's my table. Column D is what I'm after, column E is what my poorly reworked array is returning. Cell E2 is this and is dragged down for the rest of column E. What am I doing wrong?

                P.S. I'm a fan of yours and Svetlana's. I consider myself now a pro in Excel for the most part but occasionally I get stumped. Sure enough, after a quick google search, I always end up at one of your articles which clears things up for me. This has happened consistently over the past 10 years. Pass on my thanks for that!

                In cell E2
                {=SUMPRODUCT((FREQUENCY(IF($B$1:$B$19=B2,$C$1:$C$19),$C$1:$C$19)>0)*($C$1:$C$19<C2))+1}

                RECORD;BILL_NUMBER;PO_NUMBER;SHOULD_RETURN;RETURNS_THIS
                1;B5678;300006;1;1
                2;B5678;300006;1;1
                3;INV1234;300004;1;1
                4;INV1234;300004;1;1
                5;INV1234;300014;3;4
                6;INV1234;300004;1;1
                7;INV1234;300005;2;3
                8;X5555;300009;1;2
                9;INV1240;300001;1;1
                10;INV1240;300001;1;1
                11;INV1240;300002;2;2
                12;5678910;300012;2;2
                13;5678910;300011;1;2
                14;5678910;300011;1;2
                15;B5700;300013;1;2
                16;I4529;300008;2;1
                17;I4529;300007;1;1
                18;I4529;300007;1;1

              • Sorry if I was unclear, so column D is what I want it to return. What I'm after is a suffix for the bill number. So ultimately it would return something like INV1234-1, INV1234-1, INV1234-3, INV1234-1 & INV1234-2 for that bill number. So column D is the rank of distinct PO_NUMBER for each BILL_NUMBER. For INV1234, there are 3 distinct PO_NUMBERs (300004, 300005, 300014), thus the suffixes are -1, -2 & -3.

                The reason for this is because we are converting POs to Vendor Invoices (Bill), A single Bill is matched to 3 separate POs and we can't convert the 3 POs to one Invoice. We also can't create three invoices with the same exact invoice number. We have to convert the 3 lines on PO 300004 to a vendor invoice with bill number INV1234-1. Then convert the 1 line on PO 300005 to vendor invoice INV1234-2. Then convert the 1 line on PO 300014 to vendor invoice INV1234-3.

              • Hi!
                This formula determines the rank by the condition - the same values in column B.

                =COUNT(1/FREQUENCY($C$1:$C$18*($B$1:$B$18=B1),IF($C$1:$C$18>=C1,$C$1:$C$18)))

                Highest rank at maximum values. The same values have the same rank.

              • Hmm, not sure If I'm just not getting this. I tried the formula you specified,
                =COUNT(1/FREQUENCY($C$1:$C$18*($B$1:$B$18=B1),IF($C$1:$C$18>=C1,$C$1:$C$18)))
                in cell E1 and ctrl+shift+entered then dragged down but it is returning zeros for all. I wasn't sure if the issue was in the Bill Number being a string instead of value so tried with value only but it still was returning all zeros. Do I not need a SUMPRODUCT in there somwhere?

              • Hmm, that is odd. I'm on Mac desktop client 16.61.1. It seems to behave the same as PC with Arrays. I prefer PC but maybe I should check on my other computer.

              • I tried on Excel 365 and Windows Excel (current version). The formula seems to only be returning zeros?
                =COUNT(1/FREQUENCY($C$1:$C$18*($B$1:$B$18=B1),IF($C$1:$C$18>=C1,$C$1:$C$18)))

  10. I have data for which I have calculated their mean, median, mode, standard deviation. how do I calculate their rank? should I only use mean (highest mean would be rank 1 and so on ) or should I use ''mean divided by standard deviation, i.e. signal to noise ratio (snr) '' to calculate their rank in excel? please help!
    this is the data that I need help with.
    MEAN SD
    4.4 0.753937035
    4.45 0.944513241
    4.05 1.145931017
    4.75 0.550119604
    4.5 0.827170192
    4.35 0.74515982
    4.45 0.887041208
    4.05 0.944513241

  11. I have data for which I have calculated their mean, median, mode, standard deviation. how do I calculate their rank ? should I only use mean (highest mean would be rank 1 and so on ) or should I use ''mean divided by standard deviation, i.e. signal to noise ratio (snr) '' to calculate their rank in excel? please help!
    this is the data that I need help with.
    MEAN SD
    4.4 0.753937035
    4.45 0.944513241
    4.05 1.145931017
    4.75 0.550119604
    4.5 0.827170192
    4.35 0.74515982
    4.45 0.887041208
    4.05 0.944513241

  12. Hi, I have a set of numbers:
    0,0591
    0,0556
    0,1163
    -5,7416
    0,8221
    -0,5554
    1,0672
    1,8117
    0,8832
    0
    0,2268
    1,2297
    1,5574
    0,6483
    6,2281
    2,4252
    2,8033
    5,7375
    1,8332
    0,7603
    1,7136
    0,2329

    I need to rank them closest to 0, with 0 being ranked 1, that's an easy part. But I need to treat the negative numbers as being the last on the ranking order.
    Thank You in advance!

    • Hello!
      Sorry, I do not fully understand the task. What does the “I need to rank them closest to 0, with 0 being ranked 1” phrase mean? Give an example of the expected result.

      • Hi, sorry for the confusion. Here's my task:

        List Rank Rank Needed
        0,0556 4 2
        0,1163 6 4
        0,8221 11 9
        0,0591 5 3
        0,4831 9 7
        -5,7416 1 14
        1,0672 13 11
        0,7626 10 8
        1,8117 14 12
        0,8832 12 10
        0 3 1
        0,3405 8 6
        0,2268 7 5
        -0,5554 2 13

        I use this formula, to begin with, RANK(A2;$A$2:$A$15;1), to start the list with 0 i use this: IF(A2>=0;RANK(A2;$A$2:$A$15;1)-COUNTIF($A$2:$A$15;"<0")). My question is how do I add the negative numbers to the back of my ranking list?

        • Hello!
          If I got you right, the formula below will help you with your task:

          =IF(A1>=0,COUNTIF($A$1:$A$14,">=0") - COUNTIF($A$1:$A$14,">"&$A1), COUNTIF($A$1:$A$14,"<0") - COUNTIF($A$1:$A$14,"<"&$A1) + COUNTIF($A$1:$A$14,">=0"))

          Pay attention to the following paragraph of the article above — Rank positive and negative numbers separately

          • Perfect! ?

  13. I believe in the last message I sent you regarding Ranking on Every Nth Column my formula showed E2 for the search value, it should have been F2 since the formula is searching on every other other column (Modulus 2). The formula should have been as below. This still get the SPILL error. I'd greatly appreciate if you had a solution to this. Thanks.

    =RANK.EQ(F2,IF(MOD(COLUMN($A2:$J2)-COLUMN($A2)+1,2)=0,$A2:$J2))

    • Hello!
      #SPILL! is a new Excel error that only occurs when a dynamic array hasn't enough place to display the result. There should be enough blank cells around your formula for it to write the results of the calculations. If these cells are occupied by formulas or values, an error will occur.

      For more information, please see Excel #SPILL! error - causes and fixes.

  14. Hi Folks,
    I use the Max of every nth Column using an approach from ExcelJet in the link below . When I try this with the RANK or RANK.EQ functions, I get a spill error. for example using the formula where the array of values in columns A2 though K2, and attempting to get the rank of cell E2 from every other column ( the ,2 in the formula)
    =RANK(E2,IF(MOD(COLUMN($A2:$J2)-COLUMN($A2)+1,2)=0,$A2:$J2))

    Is it possible to get the rank of a value from a range of numbers from every nth column?

    Thank you.
    Mike

    https://exceljet.net/formula/max-of-every-nth-column#:~:text=To%20get%20the%20max%20of%20every%20nth%20column%2C,be%20entered%20with%20control%20%2B%20shift%20%2B%20enter.

  15. Hi there to all followers of this...

    With regards to the simple excel rank function.

    Anyone have an idea on how to start the order from a particular given number as opposed to starting from 1?

    i.e Manipulate the Order (optional) - a number that specifies how to rank values.

    The only options with rank eq appear to be:

    If 0 or omitted, the values are ranked in descending order, i.e. from largest to smallest.
    If 1 or any other non-zero value, the values are ranked in ascending order, i.e. from smallest to largest.

    Many Thanks,

    Bobby.

    • Hello!
      For me to be able to help you better, please specify which formula you mean and describe the problem in more detail. If you want to get the N largest values starting from 1, change the second parameter in the LARGE function. It's hard for me to guess from your description, but maybe this will help.

  16. PLS help me with this: I would like to rank only those from 80 and above with 90 as the highest or rank 1.

    80
    75
    83
    88
    79
    90
    thanks :-)

    • i got it this way! i just combined rank() with IF():
      =if(A2>79,rank(A2,$A$2:$A$7),"")

      thanks anyway :-)

  17. Hi, my doubt is,how to get same rank holders names in a single cell?

    • Hello!
      I’m sorry but your task is not entirely clear to me. For me to be able to help you better, please describe your task in more detail. Please specify what you were trying to find. Give an example of the source data and the expected result.
      It’ll help me understand it better and find a solution for you.

  18. Hey, I want to rank by group but I also have duplicate values, whats the best formula without it duplicating/skipping the rank?
    Thanks!

    • duplicate and skipping the rank number I mean as below :)
      Rank Style WEEKEND SALES
      1 MZZ6495 556
      2 MZZ2170 210
      2 MZZ2282 210
      2 MZZ1560 210
      5 MZZ1539 203
      6 MZZ2443 178
      7 MZZ1982 151

    • Hello!
      The article above describes how to rank with duplicates and without duplicates.
      Please specify what you were trying to find, what formula you used and what problem or error occurred. Give an example of the source data and the expected result.
      It’ll help me understand it better and find a solution for you. Thank you.

  19. Hi,
    i need to understand, how formula works and generates percentage number ranking?
    Name Amount Percentage
    majid 20 14.29%
    sajid 70 85.71%
    ahmed 80 100.00%
    sultan 40 71.43%
    khan 30 42.86%
    majid 20 14.29%
    sajid 35 57.14%
    the formula i used =RANK.EQ(B2,$B$2:$B$8,1)/COUNT($B$2:$B$8)
    first one Majid 20 percentage 14.29%. if i divide (20/7*100) is not correct. can you explain the break up of this formula, how works?

    Thanks

  20. Hi,
    Fantastic. But what if i want to assign only 3 rank (1st, 2nd, 3rd)?

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)