Excel tutorial
/

Functions

Intermediate

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.

Книга1 - Excel
—☐✕
F2fx=СЧЁТЕСЛИ(B2:B7;"Tashkent")
ABCDEFG
1ClientCityAmountCityOrders
2AzizTashkent1 250 000Tashkent3
3DilnozaSamarkand640 000
4JavohirTashkent2 100 000
5KamolaBukhara480 000
6SardorTashkent910 000
7MalikaSamarkand1 730 000
8
ГотовоКоличество: 6
COUNTIF looks for “Tashkent” in B2:B7 and counts 3 matching cells

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).
  • 100 or "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.

Книга1 - Excel
—☐✕
ФайлГлавнаяВставкаРазметка страницыФормулыДанныеРецензированиеВидСправка
Вставить функциюАвтосуммаФинансовыеЛогическиеТекстовыеДата и времяСсылки и массивыМатематические
Библиотека функций
Диспетчер имён
Определённые имена
F2fx
ABCDEFG
1ClientCityAmountCityOrders
2AzizTashkent1 250 000Tashkent
3DilnozaSamarkand640 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.

Книга1 - Excel
—☐✕
F2fx
ABCDEFG
1ClientCityAmountCityOrders
2AzizTashkent1 250 000Tashkent
3DilnozaSamarkand640 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.
Книга1 - Excel
—☐✕
F2fx=СЧЁТЕСЛИ(C2:C7;">=1000000")
ABCDEFG
1ClientCityAmountQuestionAnswer
2AzizTashkent1 250 0001 mln and up3
3DilnozaSamarkand640 000Under 500k1
4JavohirTashkent2 100 000Not Tashkent3
5KamolaBukhara480 000
6SardorTashkent910 000
7MalikaSamarkand1 730 000
8
Готово
Three questions — three COUNTIFs. The condition is always in quotes

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).

Книга1 - Excel
—☐✕
F2fx=СЧЁТЕСЛИ(B2:B6;">="&F1)
ABCDEFG
1ProductPriceThreshold3 000 0001
2Phone Samsung A152 450 000Price ≥ threshold3
3Phone iPhone 137 900 000Phone*23
4Laptop HP6 200 000*Samsung*2
5Phone Redmi 121 850 000
6Tablet Samsung3 000 000
7
Готово
1 — change the threshold and the result updates instantly. 2 — the pattern lives in a cell: Phone* — 3, *Samsung* — 2

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.
Книга1 - Excel
—☐✕
B4fx=СЧЁТЕСЛИ($A$2:A4;A4)
ABCD
1PhoneOccurrenceDuplicate?
290 123-45-671ИСТИНА
393 555-77-881ИСТИНА
490 123-45-672ИСТИНА
597 700-11-221ЛОЖЬ
693 555-77-882ИСТИНА
790 123-45-673ИСТИНА
8
Готово
A number above 1 in column B marks a repeat. The range $A$2:A4 in B4 expands by itself as you fill down

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?

Книга1 - Excel
—☐✕
Буфер обмена
Шрифт
Выравнивание
Число
Стили
Ячейки
Редактирование
✕✓fx
ABCDEFGHIJKLMNOPQRSTUVWX
1ClientCityAmountConditionResult
2AzizTashkent1250000Tashkent
3DilnozaSamarkand6400001000000
4JavohirTashkent2100000
5KamolaBukhara480000
6SardorTashkent910000
7MalikaSamarkand1730000
8
9
10
11
Лист1
Готово

Has ExcelLab been useful?

Support the project and help us release new lessons and exercises.

Support us
Previous

86 / 154