COUNTIFS
Count cells that meet two or more conditions at once.
Spreadsheet editor
Spreadsheet editor
Syntax
=COUNTIFS(range1, criteria1, [range2, criteria2, ...])
Returns: Number Arguments
| Argument | Required | Description |
|---|---|---|
| range1 | Yes | The first range of cells to test against criteria1. |
| criteria1 | Yes | The condition a cell in range1 must meet, such as 25, ">100", "West", or "A*". |
| range2, criteria2 | No | Additional range and criterion pairs. Each range must be the same size as range1, and you can add up to 127 pairs in total. |
About
Criteria can be plain values ("West"), comparisons (">1000", "<>0"), or text with wildcards ("A*" for anything starting with A). The ranges work as an AND filter, so adding more pairs narrows the count rather than widening it. Every range you list must cover the same number of rows and columns, since COUNTIFS lines them up cell by cell.
For a single condition, COUNTIF is simpler. To total or average the matching rows instead of counting them, use SUMIFS and AVERAGEIFS.
Exercises using COUNTIFS
Build a basic cohort retention table
IntermediateBuild a customer cohort retention grid by counting each signup cohort and calculating what share stayed active in later months.
Open exerciseCOUNTIFS multiple criteria
IntermediateCount orders that are both "Shipped" AND ordered in the current month.
Open exerciseRank sales reps within their region
IntermediateUse COUNTIFS to rank sales reps within their region rather than against the whole company.
Open exerciseExamples
Count between two numbers
Spreadsheet editor
AND logic, not OR
Spreadsheet editor
Threshold from a cell
Spreadsheet editor
Watch out for
Ranges that are different sizes
If your criteria ranges do not cover the same number of rows and columns, COUNTIFS returns a #VALUE! error because it cannot line the cells up.
→ Make every range the same shape, for example A2:A100 paired with B2:B100, not B2:B120.
Operators not wrapped in quotes
Writing the criterion as >500 without quotes causes an error. Comparison operators have to be inside text, like ">500".
→ Put the whole condition in quotes: ">500" or "<>Closed". To compare against a cell value, join the operator and the reference with &, like ">"&G1.
Expecting OR logic
COUNTIFS combines criteria with AND, so adding more pairs only narrows the count. It will never count a row that matches one rule but not another.
→ To count rows matching any of several rules, add separate COUNTIF or COUNTIFS results together, one per condition.
Trailing spaces and hidden text
A criterion like "Spreadsheet Center" will not match a cell holding "Spreadsheet Center " with a stray space, so your count comes up short.
→ Clean the source data with TRIM, or use a wildcard such as "Spreadsheet Center*" to allow for extra characters.