TABLE OF CONTENTS

Count Unique Values in Excel

Learn to Count Unique Values in Excel with 3 different methods

3 Minute Read

Method 1: UNIQUE and COUNTA Functions

The simplest method to count unique values in Excel uses the UNIQUE and COUNTA functions.

The UNIQUE function returns a list of unique values from a specified range. For example, in the table below, where the names Bill, Mike, and John are duplicated, by using the UNIQUE function we’re able to filter them out of the results table.

Now that we have the unique values, we need to count them, which we can do using the COUNTA function. This function counts the number of non-empty cells in a range. As you can see below, we add the COUNTA function in front of the UNIQUE function. This formula works by first generating a list of unique values using the UNIQUE function and then counting those unique values with the COUNTA function.

=COUNTA(UNIQUE(A2:A10))

With this method, we managed to count the unique values in Excel. Unfortunately, the UNIQUE function is only available for Excel 2019 and later versions. So if you use an earlier version of Excel, here’s an alternative solution.

Method 2: SUMPRODUCT and COUNTIF Functions

The second method for counting unique values in Excel uses the SUMPRODUCT and COUNTIF functions.

The COUNTIF function counts the number of cells within a range that meet a specific condition. In this case, we’ll use it to count the number of times each value appears in a range.

COUNTIF Function Syntax: COUNTIF(range, criteria)

Where the range is the range of cells to evaluate and the criteria is the condition to count, which in this case is each value in the range itself.

As you can see in the table above, the COUNTIF(B3:B9,B3:B9) counts how many times each value B3:B9 appears within the same range.

To focus on unique values, you calculate the reciprocal (1 divided by the count) of each element in the COUNTIF array. This turns each count into a fraction where duplicates contribute less to the sum. So instead of having 1 or 2, we now have 1 or 0.5.

The next step is to use the SUMPRODUCT function to sum up the array of reciprocals. Each unique value will contribute exactly 1 to the sum because its reciprocal is 1. Duplicates will contribute less than 1 because their reciprocals are fractions.

=SUMPRODUCT(1/COUNTIF(B3:B9, B3:B9))

To summarize:

  • COUNTIF(B3:B9,B3:B9): Counts occurrences of each value in the range B3:B9.
  • 1 / COUNTIF(B3:B9,B3:B9): Computes the reciprocal of each count.
  • SUMPRODUCT(…): Sums these reciprocals to get the total count of unique values.

Method 3: Pivot Tables

The third method to count unique values in excel is to use a Pivot Table. For this, select your data range, and go to the insert tab, and click on PivotTable. In the Create PivotTable dialog box, ensure the correct range is selected. Choose where you want the PivotTable to be placed (e.g., New Worksheet or Existing Worksheet). Make sure you tick on “Add this data to the Data Model” in the popup.

Once the pivot table is set up, drag the field that contains the values you want to count (in this case the names) into the Rows area. Then Drag the same field into the values area. See the image below for reference.

Currently, it’s giving us the total count, instead of the unique count. To count unique values, click on the drop-down arrow next to the field in the Values area (in this case “Count of Name” and select Value Field Settings.

In the Value Field Settings dialog box, choose Distinct Count and this will return the count of unique values. As you can see below, we have the same result for the count of unique values as the first and second method.

Additional Resources

If you found this article useful, consider checking out our Excel for Business & Finance Course where our students have landed roles at Goldman Sachs, Amazon, Bloomberg, and other great companies!

Other Articles You Might Find Helpful

Introduction

Building a cash flow statement from scratch using a company income statement and balance sheet is one of the most fundamental finance exercises commonly used to test interns and full-time professionals at elite level finance firms.

Test hyperlink

Image caption goes here
Sample Image Insertion
Dolor enim eu tortor urna sed duis nulla. Aliquam vestibulum, nulla odio nisl vitae. In aliquet pellentesque aenean hac vestibulum turpis mi bibendum diam. Tempor integer aliquam in vitae malesuada fringilla.

Elit nisi in eleifend sed nisi. Pulvinar at orci, proin imperdiet commodo consectetur convallis risus. Sed condimentum enim dignissim adipiscing faucibus consequat, urna. Viverra purus et erat auctor aliquam. Risus, volutpat vulputate posuere purus sit congue convallis aliquet. Arcu id augue ut feugiat donec porttitor neque. Mauris, neque ultricies eu vestibulum, bibendum quam lorem id. Dolor lacus, eget nunc lectus in tellus, pharetra, porttitor.

  • Test Bullet List 1
  • Test Bullet List 2
  • Test Bullet List 3
"Ipsum sit mattis nulla quam nulla. Gravida id gravida ac enim mauris id. Non pellentesque congue eget consectetur turpis. Sapien, dictum molestie sem tempor. Diam elit, orci, tincidunt aenean tempus."

Tristique odio senectus nam posuere ornare leo metus, ultricies. Blandit duis ultricies vulputate morbi feugiat cras placerat elit. Aliquam tellus lorem sed ac. Montes, sed mattis pellentesque suscipit accumsan. Cursus viverra aenean magna risus elementum faucibus molestie pellentesque. Arcu ultricies sed mauris vestibulum.

Conclusion

Morbi sed imperdiet in ipsum, adipiscing elit dui lectus. Tellus id scelerisque est ultricies ultricies. Duis est sit sed leo nisl, blandit elit sagittis. Quisque tristique consequat quam sed. Nisl at scelerisque amet nulla purus habitasse.

Nunc sed faucibus bibendum feugiat sed interdum. Ipsum egestas condimentum mi massa. In tincidunt pharetra consectetur sed duis facilisis metus. Etiam egestas in nec sed et. Quis lobortis at sit dictum eget nibh tortor commodo cursus.

Odio felis sagittis, morbi feugiat tortor vitae feugiat fusce aliquet. Nam elementum urna nisi aliquet erat dolor enim. Ornare id morbi eget ipsum. Aliquam senectus neque ut id eget consectetur dictum. Donec posuere pharetra odio consequat scelerisque et, nunc tortor.
Nulla adipiscing erat a erat. Condimentum lorem posuere gravida enim posuere cursus diam.

Kenji Farre
Kenji Farre
Senior Instructor

Ready to Level Up Your Career?

Learn the practical skills used at Fortune 500 companies across the globe.