Count Unique Values in Excel

Count Unique Values in Excel

To count only unique values in excel, we can adopt several options, and the top ones are shown below.

  1. Count unique values using Sum and Countif function.
  2. Count unique values using SUMPRODUCT and Countif function.

Now let us discuss each of the methods in detail along with an example –

#1 Count Unique Values using SUM and COUNTIF Function

Assume you are working as a sales manager, and you have sales data in front of you. Many customers purchased the product at multiple time frame in the month. You need total customers in the month.

You can download this COUNT Unique Values Excel Template here – COUNT Unique Values Excel Template

In this example, I will discuss the method of counting unique values using the SUM function in excel with the COUNTIF function.

Below are the steps used to find count unique values using sum function –

  1. Copy the below data to your excel file.


    Count Unique Values in Excel Step 1

  2. Apply the below formula in the cell E3 to get the total unique values.


    Count Unique Values in Excel Step 2

Now let me break down the formula in detail.

The formula I have used here is:

Using SUM and COUNTIF formula 1

If you take a close at the formula, it is surrounded by curly brackets. It is not entered by me; rather, it is an indication that it is an array formula.

Once you finished with the formula before we hit enter, we need to use the key:

Ctrl + Shift + Enter this would enter those curly brackets automatically for you.

This is a bit new formula if you are working with array formulas in excel for the first time. Let me break down the formula into three pieces.

Using SUM and COUNTIF formula 1-1

Firstly I will explain the COUNTIF formula. Select the countif formula part and press F9.

Using SUM and COUNTIF formula 1-2

Now press the key F9.

Using SUM and COUNTIF formula 1-3

Now we are dividing the above values by number 1.

Using SUM and COUNTIF formula 1-4

Now Sum function add all those numbers that are appeared in the above image and gives the total as 12. Therefore the total number of unique values in the list is 12.

How Does Calculation work?

  • If the values are there in the list two times, then it is ½, i.e., 0.5. If the value is there in the list three times, then it is 1/3, i.e., 0.3333.
  • In our list, the first name is Ruturaj that is appearing three times in the list, so our result showing 0.33333333 as the value.
  • Our second name Kamal appearing only one time, and the formula read like this 1/1 I .e.1 only.
  • This COUNTIF and SUM function can give us the total number of unique values in the list.

#2 Count Unique Values using SUMPRODUCT and COUNTIF Function

Take the same data from the previous example.

In this example, I will discuss the method of counting unique values using the SUMPRODUCT function Using The SUMPRODUCT FunctionThe SUMPRODUCT function in excel is used to multiply the array or range and provide the sum of a product. It is to calculate a weighted average. SUMPRODUCT formula is used to calculate the sum of corresponding numbers product in one or more ranges/arrays.read more with the COUNTIF function. This is not an array formula I am going to use in this example rather a normal formula I am using.

  • Step 1: Copy the below data to your excel file.
Count Unique Values in Excel step 1
  • Step 2: Apply the below formula in the cell E6 to get the total unique values.
Count Unique Values in Excel step 2

Now let me break down the formula in detail.

The formula I have used here is:

Using SUMPRODUCT and COUNTIF formula 1

In our previous example, I have used the Array formula, i.e., closing the formula with Ctrl + Shift + Enter.

If I break down the formula using the F9 key, it exactly works the same as the previous one.

Using SUMPRODUCT and COUNTIF formula 1-1

Now SUMPRODUCT function adds all those numbers that are appeared in the above image and gives the total as 12. Therefore the total number of unique values in the list is 12.

Handling Blanks in the Range

If the value list contains any of the empty cells, then the formula returns the result as an error in excelError In ExcelErrors in excel are common and often occur at times of applying formulas. The list of nine most common excel errors are - #DIV/0, #N/A, #NAME?, #NULL!, #NUM!, #REF!, #VALUE!, #####, Circular Reference.read more, i.e., #DIV/0!.

Handling Blanks 1

In the above image row, number 10 is the empty row. Since there is an empty row, the formula returned the result as an error, i.e., #DIV/0!.

We can handle these kinds of errors by inserting nothing ( “” ) value to it.

function 1-1

At the end of the countif formula, we need to nothing value by using an ampersand symbol then deduct the whole result by -1 because even the empty cell is treated as a unique value by the formula.

Note: If there are two empty rows, then we can use -2; if there are three empty rows, then we can use -3, and so on.

Things to Remember

Recommended Articles

This has been a Guide to Count Unique Values in Excel. Here we use COUNTIF Function along with SUM and SUMPRODUCT to count unique values in Excel along with the excel template. You may also look at these useful functions in excel –

  • 35+ Courses
  • 120+ Hours
  • Full Lifetime Access
  • Certificate of Completion
LEARN MORE >>