Countif Function in Excel With Multiple Criteria (And/Or)

In this tutorial, we will learn how to use the COUNTIF function with multiple criteria while also using the logical operators AND and OR. By combining the COUNTIF function with the logical operators AND and OR, you can create even more powerful formulas that can help you analyze your data.

Using COUNTIF with AND criteria. In this example, we have two lists of names. One list is named “Comp 1” in the A column, and another is named “Comp 2″ in the B column. In these two lists, we want to count how many times “John” and “Linda” are in the same row. To do this, we use the COUNTIFS function and the AND operator. Here is a step-by-step guide to using these features:

  1. Select the cell where you want to apply the COUNTIFS function
  2. In the formula bar, type in the formula: =COUNTIFS(A2:A7, “John”, B2:B7, “Linda”)
  3. Press Enter to see the result, which shows the number of rows of cells that have “John” in A2:A7 and “Linda” in B2:B7.
  4. In this example, the result is 2 because there are 2 rows of cells that have “John” in the Comp 1 range and “Linda” in the Comp 2 range.

Note: To add more criteria, you can add additional range-criteria pairs within the COUNTIFS formula and separate them with commas. Keep in mind that for the AND operator to work, all criteria must be met for the cell to be counted.

Using COUNTIF with OR criteria. Using the same example, we want to count how many times “John” appears in Comp 1 and how many times “Linda” appears in Comp 2. To do this, we use the COUNTIF function and the OR operator. Here is a step-by-step guide to using these features:

  1. Select the cell where you want to apply the COUNTIF function
  2. In the formula bar, type in the formula: =COUNTIF(A2:A7, “John”) + COUNTIF(B2:B7, “Linda”)
  3. Press Enter to see the result, which shows the number of cells that have either “John” in A2:A7 or “Linda” in B2:B7
  4. In this example, the result is 5 because there are 2 cells with “John” in the A2:A7 range and 3 cells with “Linda” in the B2:B7 range.

Keep in mind that for the OR operator to work, only one of the criteria must be met for the cell to be counted. You can use this method to add more criteria by adding more COUNTIF functions and separating them with the + operator. Additionally, you can also use this method with other functions such as SUMIF and other logical reasoning.

Conclusion

Using the COUNTIF and COUNTIF functions with the AND and OR operators allows you to analyze your data in a more powerful way by counting the number of cells that meet specific criteria. The AND operator requires that all criteria be met for a cell to be counted, while the OR operator only requires that one of the criteria be met. Remember to specify the range of cells where you want to apply the function and add more criteria as needed by adding more COUNTIF functions and separating them with the + operator or “,” in the case of COUNTIFS.