Example 1
Two text conditions
B13 =COUNTIFS(A2:A11,"Leeds",B2:B11,"Late")
Result: 3
Rows 3, 8 and 10 are both from Leeds and Late.
B13 =COUNTIFS(A2:A11,"Leeds",B2:B11,"Late") returns 3
Counts the rows that meet two or more conditions at once, such as late orders from one warehouse.
Syntax
=COUNTIFS(, , [criteria_range2, criteria2], ...)
Excel 2007 and later, including Excel for Microsoft 365 and Excel for the web.
Try it
Edit the formula in B13 or change the inputs. The sheet recalculates as you type.
B13 =COUNTIFS(A2:A11,"Leeds",B2:B11,"Late") returns 3
COUNTIFS counts the rows where every condition is true. It extends COUNTIF to questions like "how many late orders came from Leeds?" or "how many deals over 8,000 are qualified?".
Each condition is a pair: a range to test and a criterion to test it with. Excel checks the first pair on every row, then the second, and counts a row only when all pairs pass.
=COUNTIFS(A2:A11, "Leeds", B2:B11, "Late")
The ranges can be in different columns, but they must have exactly the same number of rows and columns. If they differ, COUNTIFS returns #VALUE!.
You can test one column twice to build a range. To count days late from 1 to 5 inclusive:
=COUNTIFS(C2:C11, ">=1", C2:C11, "<=5")
The same approach counts dates between two dates held in cells: =COUNTIFS(B2:B11,">="&F1,B2:B11,"<="&F2).
Criteria work as they do in COUNTIF: a bare value means equals, comparisons go in quotes with the operator (">3", "<>Shipped"), wildcards * and ? work on text, and a cell reference reads its current value. Use "<>" for non-blank and "" for blank.
All the conditions are joined with AND. For OR logic, add two COUNTIFS results, taking care not to double-count rows that meet both, or use SUMPRODUCT:
=SUMPRODUCT(((A2:A11="Leeds")+(A2:A11="Bristol")>0)*(B2:B11="Late"))
An array of criteria also works: =SUM(COUNTIFS(A2:A11,{"Leeds","Bristol"},B2:B11,"Late")) adds the counts for each warehouse.
For a single condition, COUNTIF is shorter. To total the matching numbers, use SUMIFS. To average them, use AVERAGEIFS. To find the largest or smallest, use MAXIFS or MINIFS.
COUNTIFS is a good building block for a summary table: put the row labels in one column and the column labels in a header row, then use a mixed reference formula such as =COUNTIFS($A$2:$A$11,$E2,$B$2:$B$11,F$1) and fill it across and down.
A2:A11.">3", "<>Shipped" or "Lee*". Text and operators go in quotes.Each example is a live sheet. Change the inputs or the formula and watch the result.
Example 1
B13 =COUNTIFS(A2:A11,"Leeds",B2:B11,"Late")
Result: 3
Rows 3, 8 and 10 are both from Leeds and Late.
B13 =COUNTIFS(A2:A11,"Leeds",B2:B11,"Late") returns 3
Example 2
B13 =COUNTIFS(B2:B11,"Late",C2:C11,">3")
Result: 2
Only the 5-day and 8-day orders are late by more than 3 days.
B13 =COUNTIFS(B2:B11,"Late",C2:C11,">3") returns 2
Example 3
B13 =COUNTIFS(C2:C11,">=1",C2:C11,"<=5")
Result: 4
The same column is tested twice. Days late of 3, 5, 2 and 1 fall in the range.
B13 =COUNTIFS(C2:C11,">=1",C2:C11,"<=5") returns 4
Example 4
B14 =COUNTIFS(A2:A11,B13,B2:B11,"<>Shipped")
Result: 2
Bristol has two orders that are not shipped. Type Leeds into B13 and the answer becomes 3.
B14 =COUNTIFS(A2:A11,B13,B2:B11,"<>Shipped") returns 2
Solve it in the sheet. Every answer is checked, with hints if you need them.
Task 1 of 2
In F2, count the qualified leads that came from the source named in E2.
Answer in F2.
#VALUE! means the criteria ranges are different sizes. Make every range start and end on the same rows.COUNTIFS(C2:C11,3) counts cells equal to 3, not above 3. Put operators in quotes: ">3"."B13", is treated as the text B13. Write B13, or ">"&B13 to combine an operator with a cell.COUNTIF takes one range and one condition. COUNTIFS takes any number of range and condition pairs, and counts rows that satisfy all of them. COUNTIFS also works with one condition.
Add separate counts, such as `=COUNTIFS(A2:A11,"Leeds",B2:B11,"Late")+COUNTIFS(A2:A11,"Bristol",B2:B11,"Late")`, or use an array constant: `=SUM(COUNTIFS(A2:A11,{"Leeds","Bristol"},B2:B11,"Late"))`.
Test the date column twice: `=COUNTIFS(B2:B11,">="&F1,B2:B11,"<="&F2)`, where F1 and F2 hold the start and end dates.
The data probably has extra spaces, numbers stored as text, or a mismatch in spelling. Check the cells with LEN, and clean them with TRIM or VALUE.
Up to 127 pairs of range and criteria.
COUNTIFS is taught in Data analysis with formulas, lesson 2: COUNTIFS and AVERAGEIFS. Each lesson is a short, graded exercise like the one above.