The COUNTIFS function
COUNTIFS counts rows where every condition is true: this plan and at least 10 visits, or aged 30 and under 50. Each condition comes as a pair: which column to check, then what to look for.
You can test the same column twice, which is how you count values between two limits.
=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)
Arguments
- criteria_range1
- The first column to test.
- criteria1
- The condition for it, such as "Monthly" or ">=10".
- criteria_range2, criteria2, ...optional
- More range and condition pairs. A row is counted only if it meets all of them.
Try it
=COUNTIFS(B2:B7,"Monthly",D2:D7,">=10") in F2. Four members are on the monthly plan, but only Ava (12) and Finn (20) visited 10 or more times, so COUNTIFS gives 2.
F2
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Member | Plan | Age | Visits | Busy monthly members | ||
| 2 | Ava | Monthly | 34 | 12 | 2 | ||
| 3 | Ben | Annual | 51 | 3 | |||
| 4 | Cara | Monthly | 27 | 0 | |||
| 5 | Dylan | Annual | 45 | 15 | |||
| 6 | Erin | Monthly | 62 | 8 | |||
| 7 | Finn | Monthly | 23 | 20 | |||
| 8 | |||||||
| 9 |
Edit the formula in F2, or change the data, and press Enter.
More examples
| Formula | Result | What it does |
|---|---|---|
| =COUNTIFS(C2:C7,">=30",C2:C7,"<50") | 2 | The same column tested twice: aged 30 to 49 (Ava and Dylan). |
| =COUNTIFS(B2:B7,"Annual",D2:D7,"<5") | 1 | Annual members who rarely come in: just Ben. |
| =COUNTIFS(B2:B7,"Monthly",D2:D7,0) | 1 | Monthly members with no visits at all. |
| =COUNTIFS(B2:B7,"Monthly") | 4 | With one pair it works just like COUNTIF. |
Tips
- Every condition is joined with AND. For OR (Monthly *or* Annual), add two COUNTIFS together.
- Point conditions at cells for a summary table:
=COUNTIFS($B$2:$B$7,G2,$D$2:$D$7,">="&H1).
Common mistakes
- #VALUE! appears.The ranges cover different rows. Make every range the same size, e.g. all
2:7. - The count is 0.No row meets *all* the conditions. Check each one on its own with COUNTIF to find the one that's too strict or misspelt.
- Ages between two values aren't counted properly.Use two separate conditions on the same range (
">=30"and"<50"); a single"30-50"is just text.
Practise COUNTIFS with instant feedback
Type real formulas into a working spreadsheet and get told straight away whether they work.