How to Ignore Duplicates in Count in Excel

Working with big datasets in Excel often means counting how many times a value appears. But sometimes, you only want to count each value once, ignoring any duplicates. Luckily, Excel has several ways to do this. In this blog, we'll show you how to ignore duplicates and count only unique values using different methods, with examples.

Method 1: Using COUNTIF to Count Unique Values

Excel's COUNTIF function is great for counting specific values. But, to ignore duplicates, you need to use it with other tricks.

Example:

Let’s say you have a list of fruits in column A:

A
Apple
Banana
Apple
Orange
Banana
Apple

You want to know how many unique fruits there are.

Step 1: Use COUNTIF to count unique items.

=SUM(1/COUNTIF(A1:A6, A1:A6))

Explanation:

  • COUNTIF(A1:A6, A1:A6) counts each value's occurrence.
  • Dividing 1 by this count makes each item count only once.
  • SUM adds these fractions to give the total count of unique items.

Result: This formula shows there are 3 unique fruits: Apple, Banana, and Orange.

Method 2: Using the UNIQUE Function in Excel 365/Excel 2021

Excel 365 and Excel 2021 have a new function called UNIQUE. It pulls out unique values from a range of data. This makes counting unique values easy without complicated formulas.

Example:

Let’s use the same list of fruits:

A
Apple
Banana
Apple
Orange
Banana
Apple

Step 1: Use the UNIQUE function to get unique values.

=UNIQUE(A1:A6)

This formula returns:

Unique Fruits
Apple
Banana
Orange

Step 2: Count these unique fruits with COUNTA.

=COUNTA(UNIQUE(A1:A6))

Result: This formula shows there are 3 unique fruits.

Method 3: Using PivotTables to Count Unique Entries

PivotTables are a great tool in Excel for summarizing data. They help count unique values by organizing your data.

A
Apple
Banana
Apple
Orange
Banana
Apple

Step 1: First, pick your data and go to the Insert tab. Then, choose PivotTable.

Step 2: In the PivotTable Field List, drag the Fruit field into both the Rows and Values areas.

Step 3: In the Values area, click on the drop-down next to “Count of Fruit”. Then, select Value Field Settings. Choose Distinct Count (available in Excel 2013 and later).

Result: This will show you the count of unique values:

Fruit Distinct Count of Fruit
Apple 1
Banana 1
Orange 1

Grand Total: 3 unique fruits.

Method 4: Using the FREQUENCY Function (for Numeric Data)

The FREQUENCY function is useful for numeric data. It counts values in a range that fall within specified ranges.

Example:

Imagine you have the following data in column A (which represents some numerical values):

A
10
20
10
30
20
40

You want to count the unique numbers.

Step 1: First, sort the data (optional but recommended for better results).

Step 2: Use the FREQUENCY function to count unique values.

=SUM(–(FREQUENCY(A1:A6, A1:A6)>0))

Explanation:

  • The FREQUENCY function counts how many values fall within specified ranges (in this case, it's checking each value against itself).
  • The double negative — converts the TRUE/FALSE results to 1/0, so SUM can count the number of unique values.

Result: This formula will return 4, because there are 4 unique numeric values: 10, 20, 30, and 40.

Method 5: Using Conditional Formatting (Visualize Unique Entries)

If you don’t need to count but just want to highlight unique values, use Excel’s Conditional Formatting feature.

Example:

With the same data:

A
Apple
Banana
Apple
Orange
Banana
Apple

Step 1: Select the range (A1:A6).

Step 2: Go to the Home tab, click on Conditional Formatting, and choose Highlight Cells Rules > Duplicate Values.

Step 3: Choose Unique in the dropdown and pick a formatting style (such as a different color).

Result: Excel will highlight the unique entries in your dataset, helping you visually identify them.

Conclusion

Excel has many ways to count or ignore duplicates, depending on your version and needs. You can use formulas like COUNTIF and FREQUENCY, or more advanced methods like UNIQUE and PivotTables. There’s always a way to make your data analysis more efficient. Try out these techniques to make your work easier and faster.

Happy counting!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.