Do you have a list of data that has some duplicates in there and you would like to count the number of unique values in the list? This is what we will go through in this article. We will go through two different ways to do this – 1) Remove duplicates and 2) with a formula. As always with Excel, there’s more than one way to do anything. Another method you may have seen on the internet is:

Remove Duplicates

This is most likely the most simple way to count how many unique values there are in a list. In the Data tab at the top, there is a Remove Duplicates function and we will make use of that.

  1. Copy the relevant array or range of data
  2. Paste it into a separate column that does not already have data in there – this is so that we will not change the original data
  3. Go to Data tab at the top
  4. Click on Remove Duplicate

    Data-Remove-Duplicates-Excel
  5. Click OK
  6. And we will see how many unique values there are in the message box:

    Remove-Duplicates-Excel-Count-Unique

Be careful if there are blanks in the list. For example below:

Careful-With-Blanks-Excel

There are only 7 numbers but the blank is counted as a value so Excel is saying there are 8 unique values. If we do not want blanks to be counted, to be absolutely sure and accurate with the number of unique values, we can then use COUNTA function to identify the number of values in the new list:

COUNTA-with-blanks-Excel

Counting Unique Values with a Formula

Using “Remove Duplicates” then COUNTA function is one way to count the number of unique values. But it may not be the most ideal approach for you. After all it is quite manual. You’ll need to copy the data and paste it into a column which doesn’t already have any data. And the adjacent (to its left and right) columns cannot have any data. You cannot update the data and get an updated result instantly. Every time you update the data, you need to follow the same steps again. So how can we count the number of unique values with just one formula?

In the very beginning of this article, we mentioned one way of doing this in a formula. That is to use the COUNTIF function, convert each result into a fraction and then use SUM to add all the fractions up. You’ll most likely find this approach very common across the internet.

But as we mentioned, there’s always more than one way to solve an issue in Excel. And here we will explore another method. The best way to approach this sort of problems (ones which there is no built-in Excel formula for) is to approach the issue logically. Ignore Excel and just think about the situation logically. We have an array of random values here and some are duplicates. How can we work out how many unique values there are? You might be able to think of a completely new approach and come up with your own formula and method. Anyway here’s how we will do it:

One way to count the number of unique values in a list is:

The formula is:

We will not go through the INDEX function in detail in this article. To find more information on INDEX function, you can have a look at our article here: Index and Match – A More Advanced Lookup. As a quick summary, the function of an INDEX formula is to locate a particular value in an array based on the relevant row and column numbers we provide. So here we go, let’s break down the formula above:

Let’s go through this with an example. Here we have three sets of data. First one is all numbers. Second one is all texts. Third is a mixture:

Excel-Random-Data-List

Essentially the formulas across the three are all the same regardless if it is all text, all numbers or a combination. The only difference is the array:

Let’s check our work with the first method we went through – Remove Duplicates and COUNTA:

Checking-work-with-counta-Excel

And we get the same results. Simple enough? There is a catch to it. So far we’ve only examined situations where the data starts from the first row. What happens when we shift the data above to start from row 2 for example? We get a #REF.

In the example we will go through what we need to update in the formula (and what we don’t need to update):

Excel-Count-Unique-Values-Excel

Formula:

Leave a Reply

Your email address will not be published. Required fields are marked *