Countifs with OR logic for multiple criteria in Excel (2024)

Normally, you can use the COUNTIFS function to count cells based on one or more conditions with AND logic in Excel. Have you ever suffered a situation where you need to count more than one value from a single column or a range of cells? This means to count with multiple conditions and OR logic. In this case, you can apply the SUM and COUNTIFS functions together, or use the SUMPRODUCT function.

Countifs with OR logic for multiple criteria in Excel (1)

  • Count cells with OR conditions in Excel
    • Count cells with OR conditions by using SUM and COUNTIFS functions
    • Count cells with OR conditions by using SUMPRODUCT function
  • Count cells with multiple sets of OR conditions in Excel
    • Count cells with two sets of OR conditions by using SUM and COUNTIFS functions
    • Count cells with multiple sets of OR conditions by using SUMPRODUCT function

Count cells with OR conditions in Excel

For example, I have a range of data as below screenshot shown, now, I want to count the number of the product which is “Pencil” or “Ruler”, here, I will discuss two formulas for solving this task in Excel.

Countifs with OR logic for multiple criteria in Excel (2)

Count cells with OR conditions by using SUM and COUNTIFS functions

In Excel, to count with multiple OR conditions, you can use the SUM and COUNTIFS functions with an array constant, the generic syntax is:

=SUM(COUNTIF(range, {criterion1, criterion2, criterion3, …}))

  • range: The data range contains the criteria where you count cells from;
  • criterion1, criterion2, criterion3…: The conditions you want to count cells based on.

To count the number of products which are “Pencil” or “Ruler”, please copy or enter the below formula into a blank cell, and then, press Enter key to get the result:

=SUM(COUNTIFS(B2:B13,{"Pencil","Ruler"}))

Countifs with OR logic for multiple criteria in Excel (3)

Explanation of the formula:

=SUM(COUNTIFS(B2:B13,{"Pencil","Ruler"}))

  • {"Pencil","Ruler"}: First, you should package all conditions in an array constant like this: {"Pencil","Ruler"}, separate the items by commas.
  • COUNTIFS(B2:B13,{"Pencil","Ruler"}): This COUNTIFS function will get individual counts for “Pencil” and “Ruler”, and you will get the result as this: {2,3}.
  • SUM(COUNTIFS(B2:B13,{"Pencil","Ruler"}))=SUM({2,3}): Finally, this SUM function sums all items in the array and returns the result: 5.

Tips: You can also use cell references for criteria, please apply the below array formula, and then press Ctrl + Shift + Enter keys together to get the correct result:

=SUM(COUNTIF(B2:B13,D2:D3))

Countifs with OR logic for multiple criteria in Excel (4)

Count cells with OR conditions by using SUMPRODUCT function

Here is another formula which is created by the SUMPRODUCT function that can help to count cells with OR logic as well. The generic syntax is:

=SUMPRODUCT(1*(range ={criterion1, criterion2, criterion3, …}))

  • range: The data range contains the criteria where you count cells from;
  • criterion1, criterion2, criterion3…: The conditions you want to count cells based on.

Please copy or enter the following formula into a blank cell, and press Enter key to return the result:

=SUMPRODUCT(1*(B2:B13={"Pencil","Ruler"}))

Countifs with OR logic for multiple criteria in Excel (5)

Explanation of the formula:

=SUMPRODUCT(1*(B2:B13={"Pencil","Ruler"}))

  • B2:B13={"Pencil","Ruler"}: This expression compares each criterion “Pencil”, “Ruler” with range cell B2:B13. If the criterion is met, it returns a TRUE, otherwise, a FALSE will display, you will get the result as this: {TRUE,FALSE;FALSE,FALSE;FALSE,FALSE;FALSE,TRUE;FALSE,FALSE;TRUE,FALSE;FALSE,FALSE;FALSE,TRUE;FALSE,FALSE;FALSE,FALSE;FALSE,TRUE;FALSE,FALSE}.
  • 1*(B2:B13={"Pencil","Ruler"}): Multiplication converts the logical values – TRUE and FALSE to 1 and 0, so it will get the result like this: {1,0;0,0;0,0;0,1;0,0;1,0;0,0;0,1;0,0;0,0;0,1;0,0}.
  • SUMPRODUCT(1*(B2:B13={"Pencil","Ruler"}))= SUMPRODUCT({1,0;0,0;0,0;0,1;0,0;1,0;0,0;0,1;0,0;0,0;0,1;0,0}): At last, the SUMPRODUCT function adds up all numbers in the array to get the result: 5.

Count cells with multiple sets of OR conditions in Excel

Sometimes, you may need to count the cells with two or more sets of OR conditions, in this case, you can use either SUM and COUNTIFS with an array constant or SUMPRODUCT with ISNUMBER MATCH functions.

Count cells with two sets of OR conditions by using SUM and COUNTIFS functions

To deal with only two sets of OR criteria, you just need to add another array constant to the COUNTIFS formula.

For example, I have the data range as below screenshot shown, now, I want to count the people who ordered “Pencil” or “Ruler” and the Amount is either <100 or >200.

Countifs with OR logic for multiple criteria in Excel (6)

Please enter or copy the following formula into a cell, and then press Enter key to get the result, see screenshot:

=SUM(COUNTIFS(B2:B13,{"Pencil","Ruler"},C2:C13,{"<100";">200"}))

Note: In the formula, you should use a semicolon for the second array constant, which creates a vertical array.

Countifs with OR logic for multiple criteria in Excel (7)

Count cells with multiple sets of OR conditions by using SUMPRODUCT function

The above formula only works for two sets of OR criteria, if you need to count with more criteria, a complex SUMPRODUCT formula together with ISNUMBER MATCH functions can help you.

Take the below data for example, to count the people who ordered "Pencil" or "Ruler" and the Status is either "Delivered" or "In transit" and signed by "Bob" or "Eko", you should apply a complex formula.

Countifs with OR logic for multiple criteria in Excel (8)

Please copy or enter the below formula into a blank cell, and then press Enter key to get the calculation, see screenshot:

=SUMPRODUCT(ISNUMBER(MATCH(B2:B13,{"Pencil","Ruler"},0))*ISNUMBER(MATCH(C2:C13,{"Delivered","In transit"},0))*ISNUMBER(MATCH(D2:D13,{"Bob","Eko"},0)))

Countifs with OR logic for multiple criteria in Excel (9)

Explanation of the formula:

=SUMPRODUCT(ISNUMBER(MATCH(B2:B13,{"Pencil","Ruler"},0))*ISNUMBER(MATCH(C2:C13,{"Delivered","In transit"},0))*ISNUMBER(MATCH(D2:D13,{"Bob","Eko"},0)))

ISNUMBER(MATCH(B2:B13,{"Pencil","Ruler"},0)):

  • MATCH(B2:B13,{"Pencil","Ruler"},0): This MATCH function is used to compare each cell in range B2:B13 with the corresponding array constant. If the match is found, it returns a relative position of the value in the array, otherwise an error value displayed. So, you will get the array list as this: {1;#N/A;#N/A;2;#N/A;1;#N/A;2;1;#N/A;2;#N/A}.
  • ISNUMBER(MATCH(B2:B13,{"Pencil","Ruler"},0))= ISNUMBER({1;#N/A;#N/A;2;#N/A;1;#N/A;2;1;#N/A;2;#N/A}):The ISNUMBER function converts the numbers to TRUEs and error values to FALSEs as this: {TRUE;FALSE;FALSE;TRUE;FALSE;TRUE;FALSE;TRUE;TRUE;FALSE;TRUE;FALSE}.

The above logic can also be applied to the second and third ISNUMBER expressions.

SUMPRODUCT(ISNUMBER(MATCH(B2:B13,{"Pencil","Ruler"},0))*ISNUMBER(MATCH(C2:C13,{"Delivered","In transit"},0))*ISNUMBER(MATCH(D2:D13,{"Bob","Eko"},0))):

  • Then, these three arrays are multiplied together inside SUMPRODUCT, which automatically converts TRUE and FALSE values to 1s and 0s as part of the math operation like this: SUMPRODUCT({1;0;0;1;0;1;0;1;1;0;1;0}*{1;1;0;0;1;1;0;1;1;0;1;1} *{1;0;0;0;0;0;0;1;0;0;1;0})=SUMPRODUCT({1;0;0;0;0;0;0;1;0;0;1;0}).
  • At last, the SUMPRODUCT function sums all numbers in the array to get the result: 3.

Relative function used:

  • SUM:
  • The Excel SUM function returns the sum of values supplied.
  • COUNTIF:
  • The COUNTIF function is a statistical function in Excel which is used to count the number of cells that meet a criterion.
  • SUMPRODUCT:
  • The SUMPRODUCT function can be used to multiply two or more columns or arrays together, and then get the sum of products.
  • ISNUMBER:
  • The Excel ISNUMBER function returns TRUE when a cell contains a number, and FALSE if not.
  • MATCH:
  • The Microsoft Excel MATCH function searches for a specific value in a range of cells, and returns the relative position of this value.

More articles:

  • Count Unique Numeric Values Based On Criteria
  • In Excel worksheet, you may suffer from a problem that count the number of unique numeric values based on a specific condition. For example, how can I count the unique Qty values of the product “T-shirt” from the report as below screenshot shown? In this article, I will show some formulas to achieve this task in Excel.
  • Count Cells That Match Two Or More Criteria
  • In Excel, to count the number of cells based on two or multiple criteria, the COUNTIFS function may help you to solve this task quickly and easily.
  • Count Number Of Rows With Multiple OR Criteria
  • To count the number of rows with multiple criteria in different columns, with OR logic, the SUMPRODUCT function can help you. For example, I have a product report as below screenshot shown, now, I want to count the rows where the product is “T-shirt” or the color is “Black”. How to deal with this task in Excel?

The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

🤖Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution |Generate Code |Create Custom Formulas|Analyze Data and Generate Charts |Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates | Delete Blank Rows | Combine Columns or Cells without Losing Data | Round without Formula...
Super VLookup: Multiple Criteria | Multiple Value | Across Multi-Sheets | Fuzzy Lookup...
Adv. Drop-down List: Easy Drop Down List | Dependent Drop Down List | Multi-select Drop Down List...
Column Manager: Add a Specific Number of Columns | Move Columns | Toggle Visibility Status of Hidden Columns | Compare Columns to ...
Featured Features: Grid Focus | Design View | Big Formula Bar | | Resource Library (Auto Text) | Date Picker | Combine Worksheets | Encrypt/Decrypt Cells | Send Emails by List | Super Filter | Special Filter (filter bold/italic/strikethrough...)...
Top 15 Toolsets: 12 Text Tools (Add Text, Remove Characters...) | 50+ Chart Types (Gantt Chart...) | 40+ Practical Formulas (Calculate age based on birthday...) | 19 Insertion Tools (Insert QR Code, Insert Picture from Path...) | 12 Conversion Tools (Numbers to Words, Currency Conversion...) | (Advanced Combine Rows, Split Excel Cells...) | ... and more

Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...

Countifs with OR logic for multiple criteria in Excel (10)

Read MoreFree Download

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.

Countifs with OR logic for multiple criteria in Excel (11)

Read More Free Download

Countifs with OR logic for multiple criteria in Excel (2024)

FAQs

Countifs with OR logic for multiple criteria in Excel? ›

COUNTIFS function

How do you use Countifs formula in Excel with multiple criteria? ›

Step 1: Document the criteria or conditions you wish to test for. Step 2: Type “=countifs(“ and select the range you want to test the first criteria on. Step 3: Input the test for the criteria. Step 4: Select the second range you want to test (it can be the same range again, or a new one).

Can you do a countif with multiple criteria sheets? ›

In Excel, COUNTIF supports multiple criteria. In Google Sheets, the COUNTIF function accepts only one data range and one criterion.

Can we use Countifs and if function together? ›

If I remember correctly you can't use an IF function inside of a COUNTIF function because the countif are automatically doing an if for the next criteria. Also I'm not sure what you are counting as your formula doesn't provide the range to count only the criteria you are looking for.

How do you write an IF formula in Excel with multiple criteria? ›

When you combine each one of them with an IF statement, they read like this:
  1. AND – =IF(AND(Something is True, Something else is True), Value if True, Value if False)
  2. OR – =IF(OR(Something is True, Something else is True), Value if True, Value if False)
  3. NOT – =IF(NOT(Something is True), Value if True, Value if False)

Can you do a countif with multiple ranges? ›

The COUNTIFS function applies criteria to cells across multiple ranges and counts the number of times all criteria are met.

Can you add two countifs together? ›

Overall, there are two ways to do this - by adding up several COUNTIF formulas or using a SUM COUNTIFS formula with an array constant.

How do I match data in Excel with multiple criteria? ›

To perform an INDEX MATCH with multiple criteria in Excel, simply use an ampersand (&) to place multiple references in your lookup value and lookup array inputs in the MATCH formula.

Does Countif work across multiple columns? ›

To be able to count across multiple columns, you will need to close out each COUNTIFS separately and then add them together. In your latest formula, you have the second COUNTIFS technically nested inside of the other. Add in two more closing parenthesis before the + and remove two from the very end of the formula.

How do you count cells if another cell meets criteria in Excel? ›

Excel COUNTIF Function
  1. Select a cell.
  2. Type =COUNTIF.
  3. Double click the COUNTIF command.
  4. Select a range.
  5. Type ,
  6. Select a cell (the criteria, the value that you want to count)
  7. Hit enter.

Can I use Countifs on multiple sheets? ›

No, the COUNTIFS needs to see how the columns relate to each other to be able to work, so it needs to be within the same sheet. That said! You can add multiple COUNTIF or COUNTIFS together.

How do you use Countifs with not equal to criteria? ›

COUNTIF greater than, less than or equal to
CriteriaFormula Example
Count if less than=COUNTIF(A2:A10,"<5")
Count if equal to=COUNTIF(A2:A10,"=5")
Count if not equal to=COUNTIF(A2:A10,"<>5")
Count if greater than or equal to=COUNTIF(C2:C8,">=5")
2 more rows

How do you use Countifs with multiple criteria? ›

COUNTIFS function

Count cells in range1 that meet criteria1. Count where range1 meets criteria1 AND range1 meets criteria2. And the SUM function returns the sum of the array as a final result. Note: this is an array formula but it doesn't require special handling in Legacy Excel when using an array constant as above.

What is the difference between Countif and Countifs? ›

The difference between COUNTIF and COUNTIFS is that COUNTIF is designed for counting cells with a single condition in one range, whereas COUNTIFS can evaluate different criteria in the same or different ranges. When doing financial analysis, COUNTIF helps in doing a quick analysis.

How do you write a countifs formula? ›

The COUNTIFS function is a premade function in Excel, which counts cells in a range based on one or more true or false condition. It is typed =COUNTIFS : =COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)

How to use countif formula in Excel with example? ›

For example, =COUNTIF(A2:A5,"apple?") will count all instances of "apple" with a last letter that could vary.

Can you use Countifs for multiple columns? ›

You can use the COUNTIFS function in Excel to count cells in a single range with a single condition as well as in multiple ranges with multiple conditions. If the latter, only those cells that meet all of the specified conditions are counted.

How do I use Countif for multiple rows? ›

The COUNTIFS will only count rows where all criteria are true. The way it works is that you list a column or range (e.g. your "Range 1") then a criteria (your "Cardiology"). Then you list another column or range ("Range 2") and your next criteria ("YES"). These have to be true in the same row.

Top Articles
Latest Posts
Article information

Author: Dan Stracke

Last Updated:

Views: 5895

Rating: 4.2 / 5 (43 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Dan Stracke

Birthday: 1992-08-25

Address: 2253 Brown Springs, East Alla, OH 38634-0309

Phone: +398735162064

Job: Investor Government Associate

Hobby: Shopping, LARPing, Scrapbooking, Surfing, Slacklining, Dance, Glassblowing

Introduction: My name is Dan Stracke, I am a homely, gleaming, glamorous, inquisitive, homely, gorgeous, light person who loves writing and wants to share my knowledge and understanding with you.