## Posts Tagged ‘Index() Function’

## Who’s On First?–Ranking Performance Using Excel

#### Introduction

No this isn’t a variation on the classic Abbott and Costello comedy routine. It’s a discussion of how to use an excel formula to arrange members of a group according to some sort of performance criteria.

One way of finding out who the top performers in a list are is to sort the list in descending order by the value that reflects the performance. Of course, that would mean having to re-sort the list every time you want to see the new ranking.

This article will demonstrate how to perform ranking without resorting the underlying list using formulas. These formulas use three excel functions, LARGE(), INDEX(), and MATCH() to rank individuals according to their total sales.

The companion workbook for this article, RANKER.xlsx can be downloaded from here. All data in the workbook is fictitious.

#### The Challenge

We have a large list of sales representatives. We want to know, *without sorting the list,* the names of the top 10 sales people. The leaders list should always display the current top 10 sellers based on current data in the sales representatives list.

At first glance, this problem seems to call for some sort of lookup functionality. Unfortunately VLookup() is not up to the challenge because that function can only use the first column of a table or list as an index to the list. Or list of sales representatives has the person’s id or employee number in in its first column.

The more general Lookup() function is also unsuitable because the index list it refers to must be sorted in ascending order.

#### The Functions

For complete descriptions of the functions used in this example refer to linked help pages, LARGE(), INDEX(), and MATCH().

**LARGE **The Large() function searches a list of values and returns the value that is in the relative position in the list that you specify. For example, you can find the largest value in a list without having to sort the list. The function is very flexible because it has an argument that lets you specify any specific relative position in the list from 1 (largest value) to the very last position (by specifying a number equal to the total number of items in the list. All this can be done without ever having to sort the list.

**INDEX **The Index() function returns the value found at a specific position in a list.

**MATCH **The Match() function searches a list and returns the number of the list row in which the value you have said to search for is found. The example used in this article specifically uses a one-column list. If the list contains duplicate values, Match will find one of the duplicates over and over for as many times as the value is duplicated.

#### Solving the Duplicates Issue

While the probability of two representatives having exactly the same Sales value may be low, the very possibility that a duplicate might exist necessitates a strategy to deal with duplicates should they occur.

In this example, we have used a bit of formula trickery to create a unique way of identifying duplicate values.

This formula when copied down a column will count the instance of a value in the specified range.

COUNTIF($E$2:E2,E2)

Notice the use of mixed references in the first argument. For this technique to work, the list may not be formatted as an Excel 2007/2010 Table. If the data is formatted as a Table, convert it to a range before entering the formula.

This expression is part of the more complex formula contained in cells F2 to F224 on the Demo_Notable worksheet. When copied down a column the reference to the start of the range remains fixed on E2 while the end of the range and the criteria cell reference are incremented for each successive reference.

However, that’s not the formula trickery I mentioned. In order to use the Large() function, we need numeric values. At the same time, in order to create a useful identifier that will not distort results, we need to work with numbers formatted as text. The trick is to convert intermediate calculations to text and then reconvert the final result back to a number, not just the textual representation of the number.

This is what the full formula looks like

=VALUE(TEXT(E2,"00000000")&TEXT(COUNTIF($E$2:E2,E2),"0000"))

When you copy this formula down the column, say to E3, Excel modifies the relative cell references. So in Row 3 the formula would become:

=VALUE(TEXT(E3,"00000000")&TEXT(COUNTIF($E$2:E3,E3),"0000"))

The idea is to convert the Sales value to text with a fixed number of digits and then concatenate the text value with the text representation of the count of duplicates. Simple adding the two values together arithmetically would distort the value and not bring us any closer to having unique value that will distinguish between duplicate instances. COUNTIF() is counts how many times the value of interest occurs in the specified range, which grows row by row as copy the formula down the column.

Here’s what the formula looks like when you copy it down several rows. Notice that the second argument of the CountIf() function changes the end of the range being counted for each row the formula is copied to. However, the range beginning is anchored to cell E2 because that part of the reference is absolute.

Caution: Using this technique with a very large list may be very slow. For lists of a few hundred items or less should not be affected.

#### The Final Solution

Six formulas drive the solution. Here are the formulas from the second row of the try it worksheet. Once the individual formulas have been created they can be copied down their respective columns (using autofill.)

The formula in F2 converts the sales value in E2 to Text and concatenates that value with a four character representation of the result of counting the frequency with which the value in E2 appears. This gives us a unique index value that ensures we will be able to find each instance of the duplicate value.

In I2 the formula finds the value in column E that is x positions from the largest value. H2 contains the value 1, so the formula in I1 returns the largest value from the list. This result is not quite adequate because it can’t distinguish duplicate values.

J2 finds the row number of the value in I2. When there are duplicate values in column E, the result in this column will always indicate the first row in which the value occurs.

The formulas in K2 and L2 are very similar to those in I2 and J2 EXCEPT the formula in K2 uses values in column F to determine rank. The forumlas in column F ensure that there are no duplicates to be ranked. The method uses has a significant side effect because it yields an higher rank for the first occurrence of a duplicate and progressively lower ranks for each subsequent occurrence.

The video accompanying this article includes a demonstration of the effect of duplicates on ranking.

The final formula in cell M2 uses the row number calcluation in L2 to find the name of the rep having a particular rank.