formulastreak

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

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.

Q3 sales team · edit I1 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultI1 = 1
ABCDEFGHI
1RepRegionJulAugSepTargetSouth > 10k Jul1
2Amara OseiNorth$12,400$13,100$11,800$36,000
3Ben FischerSouth$9,800$10,250$12,100$30,000
4Lina ChenEast$15,200$14,800$16,900$45,000
5Diego AlvarezWest$8,700$9,100$8,400$28,000
6Eva NovakNorth$11,200$12,600$13,900$36,000
7Farid HaddadSouth$13,300$12,900$14,100$39,000
8Grace KimEast$10,100$9,600$10,800$33,000
9Hugo MartinWest$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. 1. COUNTIFS: Counts the rows where B2:B9 is equal to "South" and C2:C9 is greater than 10000.
    • range1 = `B2:B9`: the first column to check
    • criteria1 = `"South"`: what it must match
    • range2 = `C2:C9`: the next column to check
    • criteria2 = `">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

ArgumentRequiredWhat it is
criteria_range1YesThe first range to test, such as the Region column B2:B9.
criteria1YesIts condition: a value ("South"), a comparison in quotes (">10000"), a cell, or a wildcard ("an").
criteria_range2, criteria2, ...NoMore 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.

Practise COUNTIFS on a live sheet

Lesson 20, COUNTIF, AVERAGEIFS and MAXIFS (Unit 5, Conditional totals), has 6 graded exercises, checked instantly, with steps and hints when you're stuck. Pro