Conditional totals function
COUNTIFS function in Google Sheets and Excel
COUNTIFS counts the rows that meet every one of several conditions, each tested on its own range.
Checked against Microsoft's and Google's documentation on · Example calculated on a live sheet
- Excel 2016
- Excel 2019
- Excel 2021
- Excel 2024
- Microsoft 365
- Google Sheets
Syntax
COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)Arguments in [brackets] are optional. Google Sheets writes it COUNTIFS(criteria_range1, criterion1, [criteria_range2, criterion2, ...]).
Example
=COUNTIFS(B2:B9,"South",C2:C9,">10000") reads: Count the rows where Region (B2:B9) is "South" and July (C2:C9) is more than 10,000.
| A | B | C | D | E | F | G | H | I | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | Rep | Region | Jul | Aug | Sep | Target | South > 10k Jul | 1 | |
| 2 | Amara Osei | North | $12,400 | $13,100 | $11,800 | $36,000 | |||
| 3 | Ben Fischer | South | $9,800 | $10,250 | $12,100 | $30,000 | |||
| 4 | Lina Chen | East | $15,200 | $14,800 | $16,900 | $45,000 | |||
| 5 | Diego Alvarez | West | $8,700 | $9,100 | $8,400 | $28,000 | |||
| 6 | Eva Novak | North | $11,200 | $12,600 | $13,900 | $36,000 | |||
| 7 | Farid Haddad | South | $13,300 | $12,900 | $14,100 | $39,000 | |||
| 8 | Grace Kim | East | $10,100 | $9,600 | $10,800 | $33,000 | |||
| 9 | Hugo Martin | West | $14,500 | $15,800 | $15,100 | $42,000 |
I1 shows 1: of the two South reps, only Farid sold more than $10,000 in July.
How the spreadsheet calculates it
Counts the rows where B2:B9 is equal to "South" and C2:C9 is greater than 10000.
- 1. COUNTIFS: Counts the rows where
B2:B9is equal to"South"andC2:C9is greater than10000.range1=`B2:B9`: the first column to checkcriteria1=`"South"`: what it must matchrange2=`C2:C9`: the next column to checkcriteria2=`">10000"`: what that must match. Add more pairs as needed
More COUNTIFS examples
=COUNTIFS(C2:C9,">=10000",C2:C9,"<15000")Julys from 10,000 up to 15,000.=COUNTIFS(B2:B9,I2,E2:E9,">"&I3)Reps in the region in I2 whose September beat the number in I3.=COUNTIFS(E2:E13,"Plants",H2:H13,"Shipped")Plant orders that have shipped.=COUNTIFS(B2:B13,">="&DATE(2026,3,1),B2:B13,"<"&DATE(2026,4,1))Orders dated in March 2026.
Paste any of these into the formula explainer to see it step by step.
Tips
- Make every range the same height, starting on the same row.
- Put the conditions in cells so the count updates when someone changes them.
- For dates, compare with
">="&DATE(…)rather than typing a date as text.
What COUNTIFS is used for
How many orders were shipped this month, how many reps in a region hit target, how many tickets are open and high priority, and the count column in summary tables by two dimensions (region × month).
Arguments
| Argument | Required | What it is |
|---|---|---|
| criteria_range1 | Yes | The first range to test, such as the Region column B2:B9. |
| criteria1 | Yes | Its condition: a value ("South"), a comparison in quotes (">10000"), a cell, or a wildcard ("an"). |
| criteria_range2, criteria2, ... | No | More range and condition pairs, up to 127 in all. A row is counted only when every pair matches.Watch out: Each extra range must have the same number of rows and columns as criteria_range1. |
Common mistakes
Ranges of different heights: COUNTIFS shows #VALUE!.
Expecting OR between the conditions: COUNTIFS counts rows that match all of them. For "North or South", add two COUNTIFS together.
Trying to write a range of values in one criteria, like "10000-15000": give the column twice, once with ">=10000" and once with "<15000".
In Google Sheets
Google Sheets' COUNTIFS takes the same pairs, written COUNTIFS(criteria_range1, criterion1, [criteria_range2, criterion2, ...]).
Errors you may see with COUNTIFS
- #VALUE!: The ranges have different sizes, a criteria string is longer than 255 characters, or a range points into a closed workbook.
Questions
How do I count values between two numbers?
Use the same column twice: =COUNTIFS(C2:C9,">=10000",C2:C9,"<15000") counts the Julys from 10,000 up to (not including) 15,000.
How do I count with OR instead of AND?
Add one count per option: =COUNTIFS(B2:B9,"North")+COUNTIFS(B2:B9,"South"). Each row can only be one region, so nothing is counted twice.
How do I use a cell in the criteria?
A cell on its own means "equal to": COUNTIFS(B2:B9,I2). For a comparison, join the operator to the cell: ">"&I3. See COUNTIF with a cell reference.
COUNTIF or COUNTIFS?
COUNTIF takes one condition; COUNTIFS takes one or more and works for a single condition too. See COUNTIF vs COUNTIFS.
Sources
Official documentation the facts on this page were checked against.