COUNTIF with Two Criteria in Excel (3 Ways)

Formulas & functions · Updated November 22, 2026

Use COUNTIFS to count cells that meet two criteria at once: =COUNTIFS(range1, criterion1, range2, criterion2). For example, =COUNTIFS(A2:A20, "North", B2:B20, ">100") counts rows where region is North and sales exceed 100. This article explains the function, its alternatives, and common pitfalls.

Why COUNTIF Alone Isn’t Enough

The single-criterion COUNTIF function counts cells in one range that match one condition. To apply two criteria, you might be tempted to add two COUNTIFs together, but that counts rows that meet either condition, not both. For instance, =COUNTIF(A2:A20,"North")+COUNTIF(B2:B20,">100") counts all North rows plus all high-sales rows, double-counting rows that satisfy both. That’s why Microsoft introduced COUNTIFS in Excel 2007 — it applies multiple conditions across paired ranges using AND logic.

How COUNTIFS Works: Syntax and Logic

The syntax is =COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...). Each range must have the same number of rows and columns, though they can be different columns. The function counts a row only if every condition is true for that row. You can include up to 127 range/criteria pairs in modern Excel.

Criteria can be numbers, text, cell references, or expressions. Text criteria are case-insensitive. Use wildcards: * for any sequence, ? for a single character. For example, to count names starting with “J” in A2:A20 and sales over 50 in B2:B20: =COUNTIFS(A2:A20, "J*", B2:B20, ">50").

Real Examples with Worked Results

Assume data in A2:B20: column A has region names (North, South, East, West), column B has sales numbers. To count North region sales above 100, with the formula =COUNTIFS(A2:A20, "North", B2:B20, ">100"), if there are 5 rows with North and 3 of those have sales above 100, the result is 3. Note that the criteria “>100” is text, so it must be in quotes. If you reference a cell containing 100, use ">"&C1 to concatenate.

Another common example: count orders between two dates. With dates in A2:A20 and product in B2:B20, to count product “Widget” ordered in January 2024: =COUNTIFS(B2:B20, "Widget", A2:A20, ">=1/1/2024", A2:A20, "<=1/31/2024"). Excel stores dates as serial numbers, so direct date text works if the cell is formatted as a date; for safety, use DATE(2024,1,1) inside the formula: =COUNTIFS(B2:B20, "Widget", A2:A20, ">="&DATE(2024,1,1), A2:A20, "<="&DATE(2024,1,31)).

Alternatives: SUMPRODUCT and FILTER

If you need more flexibility, SUMPRODUCT can count with two criteria without requiring contiguous ranges: =SUMPRODUCT((A2:A20="North")*(B2:B20>100)). This multiplies boolean arrays (TRUE/FALSE become 1/0) and sums them. It works in all Excel versions but is less efficient on large datasets.

For Excel 365, the FILTER function can return matching rows, and you can wrap it in COUNTA: =COUNTA(FILTER(A2:A20, (A2:A20="North")*(B2:B20>100))). This is dynamic and useful when you also want to see the matching rows. However, COUNTIFS is simpler and faster for pure counting.

Common Mistakes and How to Avoid Them

  • Mismatched range sizes: If criteria_range1 has 10 rows and criteria_range2 has 9, COUNTIFS returns #VALUE!. Always ensure ranges are the same size.
  • Using AND logic when you want OR: COUNTIFS only does AND. For OR (e.g., count North OR South), use =COUNTIFS(A2:A20,"North")+COUNTIFS(A2:A20,"South") or =SUMPRODUCT((A2:A20="North")+(A2:A20="South")).
  • Quoting numbers incorrectly: For numeric criteria, don't put quotes around the number unless using an operator. "100" works as text but may ignore numeric formatting. Use 100 or ">100".
  • Blank cells: COUNTIFS ignores blanks unless you use "" as a criterion. To count non-blank in a range, use "<>".
  • Date criteria as text: If you type "1/1/2024" in quotes, Excel may interpret it as a string, not a date. Use DATE() as shown above.

Excel Versions and Mac Differences

COUNTIFS is available in Excel 2010 and later, including Excel for Microsoft 365, Excel 2021, and Excel for the web. On Mac, the function works identically; the only difference is keyboard shortcuts. To enter a formula, press Enter on Windows, Return on Mac. For array formulas with SUMPRODUCT, no special entry is needed. FILTER requires Excel 365 or Excel 2021; it is not in older versions.

Performance and Large Datasets

COUNTIFS is optimized for speed, but on very large datasets (hundreds of thousands of rows), it can slow down if used in many cells. For better performance, consider using a PivotTable or Power Query to summarize data. Also, avoid using entire columns like A:A because it calculates over a million rows; instead, use a defined range like A2:A10000.

Frequently Asked Questions

Can COUNTIFS count across two different sheets?

Yes, you can reference ranges on different sheets, but each range must be on the same sheet as its pair. For example, =COUNTIFS(Sheet1!A2:A20, "North", Sheet2!B2:B20, ">100") is valid, but the ranges don't have to be on the same sheet as each other. However, they must have the same number of rows.

How do I count with two criteria in Google Sheets?

Google Sheets has the same COUNTIFS function with identical syntax. The main difference is that Google Sheets uses commas as argument separators (same as Excel), but if your locale uses semicolons, you'll need semicolons. Also, Google Sheets does not require the ranges to be the same size; it will use the smaller range, which can cause unexpected results, so always match sizes.

What if I want to count cells that meet either of two criteria?

Use two COUNTIFS added together, or use SUMPRODUCT with addition. For example, =COUNTIFS(A2:A20,"North",B2:B20,">100")+COUNTIFS(A2:A20,"South",B2:B20,">100") counts rows that are North or South with sales over 100. Be careful about double-counting if a row could meet both — in this case, a row can't be both North and South, so it's safe.

Why does COUNTIFS return 0 when I see matching data?

Check for leading/trailing spaces in your data. Use =TRIM(A2) to clean. Also, check that your criteria text matches exactly, including case (though COUNTIFS is case-insensitive, spaces matter). For numeric criteria, ensure the cell is not stored as text — use =ISNUMBER(B2) to test.

Can I use wildcards with COUNTIFS?

Yes, for text criteria. Use * for any sequence, ? for a single character. For example, =COUNTIFS(A2:A20, "N*", B2:B20, ">0") counts regions starting with N. To count cells that contain a literal asterisk, use a tilde ~*.

Is there a way to count unique values with two criteria?

COUNTIFS counts all matching rows, not unique values. To count unique combinations, use SUMPRODUCT with COUNTIFS in an array formula, or use the newer UNIQUE function in Excel 365: =COUNTA(UNIQUE(FILTER(A2:B20, (A2:A20="North")*(B2:B20>100)))) counts unique rows. This is more advanced but works.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.