SheetsLessons
Conditional function

COUNTIF function in Google Sheets

COUNTIF counts the cells in a range that meet one condition: how many orders came from the West, how many scores are above 80, how many emails end in gmail.com.

Syntax

=COUNTIF(range, criterion)
range
The cells to test.
criterion
The condition: a value ("West"), a comparison in quotes (">1500"), a wildcard pattern ("M*"), or a cell reference.

Practice COUNTIF

Task 1 of 3

How many orders came from the West region? Answer in E2.

E2
fx

Tip: while typing a formula, click a cell or drag across cells to insert references. Press Enter to check, and Tab to accept a function suggestion.

COUNTIF examples

Each example below runs against this sample sheet. The results are calculated by the same engine as the practice grid.

ABCDE
1RepRegionProductUnitsRevenue
2AvaWestMonitor12$2,400.00
3LiamEastKeyboard30$1,500.00
4MayaWestMouse45$900.00
5NoahNorthMonitor8$1,600.00
6ZaraEastMonitor15$3,000.00
7OmarWestKeyboard22$1,100.00
Sales by rep
FormulaResultWhat it shows
=COUNTIF(B2:B7, "West")3Matching is not case-sensitive.
=COUNTIF(E2:E7, ">1500")3Comparison operators go inside the quotes.
=COUNTIF(C2:C7, "M*")4* matches any characters: products starting with M.
=COUNTIF(B2:B7, "<>West")3<> means "not equal to".

Tips and common mistakes

  • To compare against a cell, join the operator and the reference: =COUNTIF(E2:E7, ">" & G1).
  • Use ? to match exactly one character, and ~* or ~? to match a literal asterisk or question mark.
  • For two or more conditions, switch to COUNTIFS.

Related functions