Going Stellar

Home/Google Sheets reference

Google Sheets function · Math

COUNTIFS in Google Sheets: syntax and examples

COUNTIFS counts the rows where every condition is true. Each condition is a range and a criterion, and the pairs work as AND. For OR, add two COUNTIFS together.

Syntax

COUNTIFS(criteria_range1, criterion1, [criteria_range2, criterion2, ...])

Arguments

ArgumentTypeRequiredWhat it does
criteria_range1rangeyesThe first range to test.
criterion1anyyesThe condition for the first range: a value, a comparison such as ">100", or a pattern with * and ?.
criteria_range2, criterion2, ...anynoMore range and condition pairs. Every range must have the same size as the first one.

Examples

The examples use this table, starting in A1:

OrderStatusCountryTotal
#1001paidRO120
#1002refusedRO80.5
#1003paidBG200
#1004paidRO45
#1005refusedBG60
=COUNTIFS(B2:B6, "paid", C2:C6, "RO")

Result: 2

Paid orders from Romania. A row is counted only if both conditions hold.

Run in a Google Sheet (English US locale) on .

=COUNTIFS(D2:D6, ">100")

Result: 2

One condition with a comparison operator: totals above 100.

Run in a Google Sheet (English US locale) on .

=COUNTIFS(B2:B6, "paid", D2:D6, ">=100")

Result: 2

Mix text and number conditions: paid orders worth at least 100.

Run in a Google Sheet (English US locale) on .

=COUNTIFS(D2:D6, ">80.5")

Result: 2

A decimal inside the criterion follows the locale: a dot in EN, a comma in RO.

Run in a Google Sheet (English US locale) on .

=COUNTIFS(B2:B6, "<>refused", C2:C6, "R?")

Result: 2

<> excludes a value and ? stands for one character, so RO matches here.

Run in a Google Sheet (English US locale) on .

Common errors

  • All ranges must have the same number of rows and columns. B2:B6 next to C2:C5 returns #VALUE!.
  • Conditions are joined by AND only. To count paid or refused, add two calls: COUNTIFS(...) + COUNTIFS(...).
  • A comparison is written as text and a cell value is joined with &: ">"&E1. Without the & the cell address is read as plain text.
  • Matching ignores case, and * and ? act as wildcards. Use ~ before them when you need a literal character.

Compared with Excel

Same syntax as Excel COUNTIFS.

Sources

  1. COUNTIFS (Docs Editors Help)

Markdown version · All functions