Sub topic 4
COUNTIFS: counting rows that meet conditions
This chapter assumes you can enter and copy formulas, know how SUM, COUNT, and AVERAGE work, and have read how the *IFS functions pair ranges with criteria. The examples use the sample sales layout: headers in row 1, data in rows 2 to 100, and columns Date (A), Region (B), Product (C), Amount (D), and Notes (E).
A: Date B: Region C: Product D: Amount E: Notes
2025-01-05 West Laptop 1200
2025-01-09 East Monitor 300 Backorder
2025-02-02 West Monitor 310
2025-02-14 North Laptop 1150 GiftWhat COUNTIFS does
COUNTIFS counts the rows where every condition is true. It differs from SUMIFS in one way: it has no sum range. You give it only pairs of a range and a criterion.
=COUNTIFS(B2:B100, "West", C2:C100, "Laptop")This counts the rows where Region is West and Product is Laptop. With the four sample rows above, the result is 1.
How a row is counted
Excel checks each row position across all the ranges. A row counts only if it passes every pair. A single pair is also valid, so =COUNTIFS(B2:B100, "West") counts West rows.
Counting with other criteria types
Every criteria form from the SUMIFS chapters works here too. Two examples:
=COUNTIFS(C2:C100, "Lap*")The * wildcard matches any run of characters, so this counts products that start with Lap. Matching ignores letter case.
=COUNTIFS(B2:B100, "West", E2:E100, "")An empty string matches blank cells, so this counts West rows that have no note. Use "<>" instead to count rows that do have a note.
Common errors
- Ranges of different sizes. If one range is
B2:B100and another isC2:C50, COUNTIFS returns#VALUE!. Every range must have the same number of rows and columns. - Counting the wrong thing. COUNTIFS counts rows, not values. A West row with an Amount of 0 still counts.
- Operators without quotes. Write
">=500"or">=" & G1, never a bare>=500.
Exercise
Write a COUNTIFS formula that counts the rows where Region is East and the Notes cell is not blank. What does it return for the four sample rows?
Show answer
=COUNTIFS(B2:B100, "East", E2:E100, "<>") returns 1, because only the East Monitor row has a note (Backorder).
Exercise
A colleague writes =COUNTIFS(B2:B100, "West", C2:C50, "Laptop") and gets #VALUE!. What is wrong, and how do you fix it?
Show answer
The two criteria ranges have different sizes (99 rows and 49 rows). Change C2:C50 to C2:C100 so both ranges cover the same rows.