FxFormula Drills

COUNTIF vs COUNTIFS

COUNTIF counts cells in one range that meet one condition. COUNTIFS counts rows that meet every condition, and each condition has its own range. COUNT counts numbers only and ignores your labels. Use COUNTIF for 'how many East rows' and COUNTIFS for 'how many East rows are also Pen'.

Syntax

COUNT

COUNT(range)

Counts cells that contain numbers. Text, including the word East, is not counted. Blanks are not counted.

COUNTIF

COUNTIF(range, criteria)

Counts cells in one range that meet one criterion. Text and comparisons go in quotes: "East", ">10".

COUNTIFS

COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)

Each pair is a range and a test. A row counts only when every test is true. Unlike SUMIFS, there is no separate sum range. The ranges must be the same size.

Comparison

QuestionCOUNTCOUNTIFCOUNTIFS
What it countsNumeric cellsCells matching one testRows matching every test
ConditionsNoneOneOne or more, as AND
A text label such as EastIgnoredCounted if it equals the criterionCounted when every pair matches
ORNot applicableAdd two COUNTIF results if the groups do not overlapAdd two COUNTIFS results if the groups do not overlap
VersionsAll current Excel and Google SheetsAll current Excel and Google SheetsExcel 2007 and later, and Google Sheets

Worked examples

How many East orders, and how many of those are Pens

Three rows are East. Two of those are also Pen. The West Pen is a Pen but not East. COUNT on the region column does not count the labels, because they are text.

East Pen 10, West Pen 40, East Book 30, East Pen 20.
RowABC
1RegionProductAmount
2EastPen10
3WestPen40
4EastBook30
5EastPen20
  • =COUNT(A2:A5) → 0
  • =COUNTIF(A2:A5,"East") → 3
  • =COUNTIFS(A2:A5,"East",B2:B5,"Pen") → 2
  • =COUNTIF(C2:C5,">10") → 3

COUNT of the region labels is 0 because none of them are numbers. COUNTIF finds three East cells. COUNTIFS keeps a row only when column A is East and column B is Pen, which is two rows. The amount threshold is a separate COUNTIF: 40, 30, and 20 are greater than 10, and 10 itself is not, so the count is 3.

Amounts over 10 that are also East

Both tests refer to different columns, so this is COUNTIFS even though one test is a comparison.

Same four amounts: 10, 40, 30, and 20.
RowABC
1RegionProductAmount
2EastPen10
3WestPen40
4EastBook30
5EastPen20
  • =COUNTIFS(A2:A5,"East",C2:C5,">10") → 2

East rows have amounts 10, 30, and 20. Greater than 10 removes the 10, leaving 30 and 20. The count is 2. The comparison stays in quotes as ">10".

When to use which

Use COUNT for 'how many numbers are filled in'

A score column where blanks should not count, and text should not count, is COUNT. The free COUNT and COUNTA drill separates COUNT from COUNTA, which also counts text.

Use COUNTIF for one question

How many orders are East. How many amounts beat the quota. The free region drill and the premium quota drill are that shape.

Use COUNTIFS when the row has to satisfy a list

East and Pen, or East and over 10. Adding another pair never means OR. Add a second COUNTIFS if you need an alternative.

Common mistakes

Using COUNT to count labels

COUNT(A2:A5) on a column of region names is 0. COUNTIF is the function that can see the word East.

Quoting a criterion that is a cell reference

COUNTIF(A2:A5, E2) reads the cell. COUNTIF(A2:A5, "E2") looks for the two characters E and 2. Quote the words and the operators, not the cell addresses.

Ranges that start on different rows

COUNTIFS pairs cells by position. A2 with B2, A3 with B3. If one range is A2:A5 and the other is B3:B6, the pairs are the wrong rows.

Confusing COUNTIF with COUNTIFS in a longer name

A formula that says COUNTIF does not become COUNTIFS because the sheet has two criteria somewhere else. The function name has to be COUNTIFS before a second pair is allowed.

Versions and compatibility

COUNT and COUNTIF are in current and older Excel and in Google Sheets. COUNTIFS is in Excel 2007 and later and in Google Sheets.

The comparison criterion ">10" is written the same way in Google Sheets. Locale differences are the argument separator and, in some locales, the decimal comma. The examples here use a decimal point and comma separators.

COUNTA, not shown in the sheet above, counts non-blank cells and is the one to use when the thing you are counting is text. It is in the free drill with COUNT.

Practice on Formula Drills

Free drills are open with no account. Premium drills show the problem to everyone and grade the sheet for subscribers.

Free exercises

Premium exercises

Function pages

FAQ

What is the difference between COUNTIF and COUNTIFS?

COUNTIF takes one range and one criterion. COUNTIFS takes pairs, and every pair must be true for the same row. Use COUNTIFS even for a single pair if you want the newer argument style. The result matches COUNTIF for that one test.

Can COUNTIFS use OR?

Not inside one call. Add two COUNTIFS results when a row cannot fall into both groups. If the groups can overlap, a helper column is safer than addition.

Does blank equal zero in a threshold?

A blank cell is not greater than 10, so COUNTIF(C2:C5, ">10") skips blanks. COUNTIF(C2:C5, 0) does not count blanks either. COUNTBLANK is the function that counts empty cells.

Why did my count include the header?

The range started on row 1 and the header text happened to match, or the header was a number. Start the range on the first data row.