Excel COUNTIF
COUNTIF counts how many cells in a range match one condition.
A small online shop wants to know how many reviews gave four stars or better and which product is reviewed most. COUNTIF answers both from one column, and it is also the simplest way to spot duplicates.
Practice it nowHow to write it
=COUNTIF(range, criteria)- range
- The cells to test.
- criteria
- The condition to meet.
Watch it work
D2fx
ABCDE
1ProductRating
2Mug5
3Mug3
4Cap4
5Bag5
6Cap2
7Mug4
8
1
Examples
How many reviews are for the Mug?
=COUNTIF(A2:A7,"Mug")3Text conditions go in quotes.
Ratings of 4 or better
=COUNTIF(B2:B7,">=4")4Comparison operators go inside the quotes.
Reviews not about the Cap
=COUNTIF(A2:A7,"<>Cap")4The <> operator counts everything else.
Your turn
Count how many ratings are exactly 5. Type your formula in D2.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Product | Rating | ||
| 2 | Mug | 5 | ||
| 3 | Mug | 3 | ||
| 4 | Cap | 4 | ||
| 5 | Bag | 5 | ||
| 6 | Cap | 2 | ||
| 7 | Mug | 4 | ||
| 8 |
Common mistakes
Using a cell inside a comparison incorrectly.
Join them: ">"&D1, not ">D1".
Long codes match when they shouldn't.
Very long numeric text can be compared as numbers. Check IDs longer than 15 digits.
Good to know
- COUNTIF(A:A,A2)>1 flags duplicates.
- Divide by COUNTA to turn a count into a share of the total.
- COUNTIF or COUNTIFS? COUNTIF has one condition. COUNTIFS needs every one of several conditions to be true.
Excelio