Excel COUNTIF function: counting by a condition — examples and traps
COUNTIF counts cells that meet a condition: text, numbers, a condition from a cell like ">"&F1, * and ? wildcards, finding duplicates. Step by step.
COUNTIF counts the cells in a range that meet one condition. “How many orders came from Tashkent?”, “How many students scored above 56?”, “How many times does this client appear in the list?” — each is a single COUNTIF.
It is one of Excel’s most used functions: in reports, in finding duplicates, in cleaning data. Learn how a condition is written once, and SUMIF, AVERAGEIF and COUNTIFS work exactly the same way.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Client | City | Amount | City | Orders | ||
| 2 | Aziz | Tashkent | 1 250 000 | Tashkent | 3 | ||
| 3 | Dilnoza | Samarkand | 640 000 | ||||
| 4 | Javohir | Tashkent | 2 100 000 | ||||
| 5 | Kamola | Bukhara | 480 000 | ||||
| 6 | Sardor | Tashkent | 910 000 | ||||
| 7 | Malika | Samarkand | 1 730 000 | ||||
| 8 |
Syntax
=СЧЁТЕСЛИ(range; criteria)
- range — where to count:
B2:B7. - criteria — what to count. Conditions are written like this:
"Tashkent"— exactly this text (case doesn’t matter).100or"100"— exactly this number.">1000000","<=56"— a comparison: sign and number inside quotes."<>Tashkent"— everything except Tashkent."Ph*"— text starting with “Ph”;*is any number of characters,?is exactly one.""— empty cells,"<>"— non-empty cells.E2— the value in a cell;">"&E2— a comparison with the number in a cell.
Step by step: entering COUNTIF through the dialog
1
Select F2 for the result.
2
Формулы → Вставить функцию. Type COUNTIF in the search box or choose the Statistical category, select COUNTIF and click OK.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Client | City | Amount | City | Orders | ||
| 2 | Aziz | Tashkent | 1 250 000 | Tashkent | |||
| 3 | Dilnoza | Samarkand | 640 000 | ||||
| 4 | |||||||
| 5 |
3
In Range, select B2:B7 with the mouse; in Criteria, type "Tashkent" (or click cell E2). The result — 3 — shows at the bottom. Click OK.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Client | City | Amount | City | Orders | ||
| 2 | Aziz | Tashkent | 1 250 000 | Tashkent | |||
| 3 | Dilnoza | Samarkand | 640 000 | ||||
| 4 | |||||||
| 5 |
4
The fast way: type =СЧЁТЕСЛИ(B2:B7;"Tashkent") straight into the cell. As you type =COUNTI, Excel shows a list — pick the function with Tab.
Example 1: conditions with numbers
When a condition has a comparison sign, both the sign and the number go inside the quotes:
=СЧЁТЕСЛИ(C2:C7;">=1000000")— orders of 1 mln and above.=СЧЁТЕСЛИ(C2:C7;"<500000")— under 500 thousand soum.=СЧЁТЕСЛИ(B2:B7;"<>Tashkent")— orders not from Tashkent.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Client | City | Amount | Question | Answer | ||
| 2 | Aziz | Tashkent | 1 250 000 | 1 mln and up | 3 | ||
| 3 | Dilnoza | Samarkand | 640 000 | Under 500k | 1 | ||
| 4 | Javohir | Tashkent | 2 100 000 | Not Tashkent | 3 | ||
| 5 | Kamola | Bukhara | 480 000 | ||||
| 6 | Sardor | Tashkent | 910 000 | ||||
| 7 | Malika | Samarkand | 1 730 000 | ||||
| 8 |
Example 2: the condition in a cell, and the * wildcard
Don’t write the threshold inside the formula — put it in a cell so it’s easy to change. The key point: the comparison sign stays in quotes and the cell is joined with &:
=СЧЁТЕСЛИ(B2:B6;">="&F1)
If you write ">=F1", Excel compares with the text “F1” and returns 0.
For partial matches use *: "Phone*" — anything starting with “Phone”, "*Samsung*" — anything containing Samsung. The pattern can live in a cell too: =СЧЁТЕСЛИ(A2:A6;E3).
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Product | Price | Threshold | 3 000 0001 | |||
| 2 | Phone Samsung A15 | 2 450 000 | Price ≥ threshold | 3 | |||
| 3 | Phone iPhone 13 | 7 900 000 | Phone*2 | 3 | |||
| 4 | Laptop HP | 6 200 000 | *Samsung* | 2 | |||
| 5 | Phone Redmi 12 | 1 850 000 | |||||
| 6 | Tablet Samsung | 3 000 000 | |||||
| 7 |
Pro level: finding duplicates and a running count
- Is it a duplicate?
=СЧЁТЕСЛИ($A$2:$A$7;A2)>1— TRUE if the value appears more than once. Use it as a conditional formatting rule to color duplicates. - Which occurrence is this?
=СЧЁТЕСЛИ($A$2:A2;A2)— the start of the range is locked ($A$2) while its end grows as you fill down. 1 means the first occurrence, 2 or more a repeat. Filter by this column to delete the repeats. - An “or” condition. COUNTIF takes one condition. Tashkent or Samarkand:
=СЧЁТЕСЛИ(B2:B7;"Tashkent")+СЧЁТЕСЛИ(B2:B7;"Samarkand"). - A share.
=СЧЁТЕСЛИ(B2:B7;"Tashkent")/СЧЁТЗ(B2:B7)— what percentage of orders came from Tashkent. - Two or more conditions (city and amount) — that’s a job for COUNTIFS.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Phone | Occurrence | Duplicate? | |
| 2 | 90 123-45-67 | 1 | ИСТИНА | |
| 3 | 93 555-77-88 | 1 | ИСТИНА | |
| 4 | 90 123-45-67 | 2 | ИСТИНА | |
| 5 | 97 700-11-22 | 1 | ЛОЖЬ | |
| 6 | 93 555-77-88 | 2 | ИСТИНА | |
| 7 | 90 123-45-67 | 3 | ИСТИНА | |
| 8 |
Try it in the simulator
Type =СЧЁТЕСЛИ(B2:B7;E2) in F2 to find how many orders came from Tashkent. Then type =СЧЁТЕСЛИ(C2:C7;">="&E3) in F3 — how many orders are 1 mln or more?
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Client | City | Amount | Condition | Result | |||||||||||||||||||
| 2 | Aziz | Tashkent | 1250000 | Tashkent | ||||||||||||||||||||
| 3 | Dilnoza | Samarkand | 640000 | 1000000 | ||||||||||||||||||||
| 4 | Javohir | Tashkent | 2100000 | |||||||||||||||||||||
| 5 | Kamola | Bukhara | 480000 | |||||||||||||||||||||
| 6 | Sardor | Tashkent | 910000 | |||||||||||||||||||||
| 7 | Malika | Samarkand | 1730000 | |||||||||||||||||||||
| 8 | ||||||||||||||||||||||||
| 9 | ||||||||||||||||||||||||
| 10 | ||||||||||||||||||||||||
| 11 |
Has ExcelLab been useful?
Support the project and help us release new lessons and exercises.