Conditional totals · About 6 minutes
Count with two conditions using COUNTIFS
COUNTIF counts rows that match one condition. COUNTIFS counts rows that match every condition you give it.
COUNTIFS has no range to add up, only pairs of "where to look, what to look for". =COUNTIFS( reads as "count the rows where the Area is North and the Payment is Venmo".
Use "<>Cash" to mean "not Cash". To count a band, test the same range twice: ">=40" and "<=100".
Part of Plus
Free during our founding launch: sign in to unlock this lesson's exercises, the timed practice sets and the rest of Plus. The free lessons stay free, with no account needed.
What COUNTIFS does
COUNTIFS counts the rows that pass every condition you give it. COUNTIF checks one condition; COUNTIFS checks several, like day shifts that ran over 8 hours.
It answers "how many" questions that need more than one test: orders from one area paid one way, or scores within a band. There is nothing to add up, only rows to count.
How to write COUNTIFS
=COUNTIFS(
- criteria_range1
- The first column to test, like the shifts in B2:B7.
- criteria1
- The test for that column, like
"Day". A sign and a number go in quotes together, like">8". - criteria_range2, criteria2, ...
- More pairs. Excel accepts up to 127. A row is counted only when it passes them all.
COUNTIFS worked example
A rota lists each person's shift and hours. In C9, count the day shifts of more than 8 hours.
| A | B | C | |
|---|---|---|---|
| 1 | Name | Shift | Hours |
| 2 | Ana | Day | 8 |
| 3 | Ben | Night | 10 |
| 4 | Cy | Day | 6 |
| 5 | Dee | Night | 12 |
| 6 | Eli | Day | 9 |
| 7 | Fay | Day | 11 |
| 8 | |||
| 9 | Day, >8 | 2 |
=COUNTIFS( B2:B7, "Day", C2:C7, ">8")Count the rows where B2 to B7 is Day and C2 to C7 is more than 8: Eli and Fay, so 2. Ana's 8 is not more than 8.Common COUNTIFS mistakes
The formula won't accept >8
Put the sign and the number inside quotes: ">8". To use a limit from a cell, join it: ">".
The cell shows an error
The ranges cover different rows. Make every range the same size, like B2:B7 and C2:C7.
Day or Night gives 0
COUNTIFS needs every test to pass, and no row is both. Add two COUNTIF results together, one for each.
COUNTIF or COUNTIFS?
Use COUNTIF for one condition and COUNTIFS for two or more. COUNTIFS with one pair gives the same answer as COUNTIF.
Both are in Excel 2007 and later and in Google Sheets. To count a band, test the same column twice, once for each end.
Questions people ask
What is the difference between COUNTIF and COUNTIFS?
COUNTIF checks one condition. COUNTIFS checks several, and counts a row only when it meets all of them.
How do I count between two numbers?
Test the same range twice: =COUNTIFS(. Use > and < instead to leave out the limits themselves.
How do I count cells not equal to a word?
Put <> before the word: =COUNTIFS(.
Can COUNTIFS use OR?
Not directly, because all conditions must be true. Add two COUNTIFS, one for each option.
Why does COUNTIFS return 0?
No row meets every condition at once, or one condition doesn't exactly match the cells. Test each condition alone with COUNTIF to find which.