How to Count Duplicates Based on Multiple Criteria in Excel

Method 1 – SUMPRODUCT Function to Count Duplicates Based on Multiple Criteria

  • Enter the following formula in cell F5,
=SUMPRODUCT(--(C5&D5=$C$5:$C$16&$D$5:$D$16))

The formula will return 1 for each unique set of regions and products and will give the number of occurrences for duplicate sets of region and product.

sumproduct

  • Press ENTER,

It will give an output of 1. That means there is only one car seller in New York. There are no duplicates.

count duplicates in excel multiple criteria

  • Drag the fill handle from cell F5 to the end of your dataset.

You will get the count of the duplicates in your dataset based on multiple criteria which are sales region and product type.

count duplicates in excel multiple criteria

Related Content: How to Count Duplicates in Column in Excel


Method 2 – COUNTIFS Function to Count Duplicates Based on Criteria

  • Enter the following formula in cell F5:
=COUNTIFS($C$5:$C$16,C5,$D$5:$D$16,D5)

The formula will return 1 for each unique set of regions and products and will give the number of occurrences for duplicate sets of region and product.

countifs

  • Press ENTER.

It will give an output of 1. That means there is only one car seller in New York. There are no duplicates.

count duplicates in excel multiple criteria

  • Drag the fill handle of cell F5 to the end of your dataset.

You will get the count of the duplicates in your dataset based on multiple criteria.

count duplicates in excel multiple criteria

Read More: How to Count Duplicates in Two Columns in Excel


Method 3 – Count Duplicates Based on Multiple Criteria Using SUM and EXACT Functions

  • Enter the following formula in cell F5:
=SUM(--(EXACT($C$5:$C$16&$D$5:$D$16,C5&D5)))

The EXACT function gives TRUE, if it finds an exact match of product and region among the range. The double dash in the formula () converts the TRUE into 1. The SUM function adds up all the ones.

sum

  • Press ENTER.

It will give an output of 1. That means there is only one car seller in New York. There are no duplicates.

exact

  • Drag the fill handle from cell F5 to the end of your dataset.

You will get the count of the duplicates in your dataset based on multiple criteria which are sales region and product type.

count duplicates in excel multiple criteria

Related Content: How to Count Duplicate Values in Multiple Columns in Excel


Method 4 – Count Duplicates by Combining Criteria Altogether

  • Enter the following formula in cell F5:
=C5&D5

It will combine the criteria from cells C5 and D5 in cell F5.

countif

  • Press ENTER.

You will get the combined criteria in cell F5.

combined

  • Drag the fill handle in cell F5 to the end of your dataset.

count duplicates in excel multiple criteria

You can use the COUNTIF function to count the duplicates.

  • Enter the following formula in cell G5:
=COUNTIF($F$5:$F$16,F5)

The formula will return 1 for unique values and the number of occurrences for duplicate values.

count duplicates in excel multiple criteria

  • Press ENTER.

It will give an output of 1. That means there is only one car seller in New York. There are no duplicates.

count duplicates in excel multiple criteria

  • Drag the fill handle of C5 to the end of your dataset.

You will get the count of the duplicates in your dataset based on multiple criteria which are sales region and product type.

count duplicates in excel multiple criteria

Read More: How to Count Duplicate Rows in Excel


Download the Practice Workbook


Related Articles


<< Go Back to Duplicates in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Prantick Bala
Prantick Bala

PRANTICK BALA is a marine engineer who loves exploring Excel and VBA programming. Programming, to him, is a time-saving tool for efficiently managing data, files, and internet tasks. He is proficient in Rhino3D, Maxsurf, C++, MS Office, AutoCAD, Excel, and VBA and goes beyond the basics. Armed with a B.Sc in Naval Architecture & Marine Engineering from BUET, he has transitioned into the role of a content developer. Beyond his work, find him immersed in books, exploring new... Read Full Bio

2 Comments
  1. Hi Prantick,
    Would you know which of the 3 first methods takes less memory?
    The 4th is already discarded because it uses 2 columns instead of one.
    Thank you very much,

    • Reply Avatar photo
      Rubayed Razib Suprov Aug 21, 2022 at 1:10 PM

      Thanks for your question, Jorge F. The allocation of memory mostly depends upon the dataset in which you are working on, and how they are interacting to other functions. For example, if you use a nested function, that function will cost more memory. There are some functions out there that consume more memory compared to other functions. Among the methods described above, the SUMPRODUCT function has more memory allocation compared to other functions. The other two methods would consume more or less the same amount of memory.

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo