COUNTIFS counts the rows in a range that meet all of the conditions you give it. That makes it the go-to function when you need answers like "how many East orders have shipped?" or "how many orders came in during January?". This tutorial walks through AND logic, OR logic, date ranges, wildcards and number conditions using one small order list, and every result shown below was checked in a real spreadsheet.
=COUNTIFS(C2:C13,"East",F2:F13,"Shipped"). Every pair must be true for a row to be counted (AND logic). For OR logic, add two COUNTIFS together or use =SUM(COUNTIFS(C2:C13,{"East","West"},F2:F13,"Shipped")).The sample data
All examples use this order list in cells A1:F13.
| Order ID | Date | Region | Product | Amount | Status |
|---|---|---|---|---|---|
| SO-1001 | 2026-01-05 | East | Laptop Pro 14 | 1250 | Shipped |
| SO-1002 | 2026-01-09 | West | Wireless Mouse | 35 | Shipped |
| SO-1003 | 2026-01-14 | East | Monitor 27 | 320 | Pending |
| SO-1004 | 2026-01-20 | North | Laptop Air 13 | 980 | Shipped |
| SO-1005 | 2026-01-27 | East | Wireless Mouse | 35 | Shipped |
| SO-1006 | 2026-02-02 | West | Laptop Pro 16 | 1890 | Cancelled |
| SO-1007 | 2026-02-06 | South | Monitor 27 | 320 | Shipped |
| SO-1008 | 2026-02-11 | East | Laptop Pro 14 | 1250 | Shipped |
| SO-1009 | 2026-02-17 | West | Keyboard Pro | 120 | Pending |
| SO-1010 | 2026-02-23 | North | Monitor 24 | 210 | Shipped |
| SO-1011 | 2026-03-03 | East | Keyboard Pro | 120 | Shipped |
| SO-1012 | 2026-03-09 | West | Laptop Air 13 | 980 | Shipped |
COUNTIFS syntax
=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)
Each condition is a pair: a range to check and the test to apply to it. You can add more pairs (Excel allows up to 127). A row is counted only when it passes every test.
1. AND logic: two conditions at once
How many orders are from the East region and have the status Shipped?
=COUNTIFS(C2:C13,"East",F2:F13,"Shipped")
Result: 4 (SO-1001, SO-1005, SO-1008 and SO-1011). SO-1003 is from the East region too, but it is still Pending, so it is not counted.
In a real workbook, put the criteria in cells so you can change them without editing the formula. If J1 holds East and J2 holds Shipped:
=COUNTIFS(C2:C13,J1,F2:F13,J2)
2. OR logic: East or West
COUNTIFS on its own only does AND. To count shipped orders from the East or the West region, you have two options.
Option A: add two COUNTIFS
=COUNTIFS(C2:C13,"East",F2:F13,"Shipped")+COUNTIFS(C2:C13,"West",F2:F13,"Shipped")
Option B: use an array constant inside SUM
=SUM(COUNTIFS(C2:C13,{"East","West"},F2:F13,"Shipped"))
Result: 6 for both (4 East + 2 West). In option B, COUNTIFS returns one count per item in the braces, {4,2}, and SUM adds them. Option B is shorter when you have many alternatives. In Google Sheets, the plain addition in option A is the safer choice; the array-constant version may need to be wrapped in ARRAYFORMULA there.
OR across different columns (avoid double counting)
Adding COUNTIFS works only when the alternatives are in the same column, because one row can't be both East and West. If you want "Region is East or Status is Pending", adding COUNTIF(C2:C13,"East") (5) and COUNTIF(F2:F13,"Pending") (2) gives 7, which is wrong: SO-1003 is East and Pending, so it gets counted twice. Use SUMPRODUCT instead:
=SUMPRODUCT(((C2:C13="East")+(F2:F13="Pending")>0)*1)
Result: 6. Each row gets 0, 1 or 2 matches; >0 turns that into TRUE/FALSE, so each row counts at most once.
3. Count between two dates
To count orders placed in January 2026, use the date column twice, once for the start and once for the end:
=COUNTIFS(B2:B13,">="&DATE(2026,1,1),B2:B13,"<="&DATE(2026,1,31))
Result: 5 (SO-1001 to SO-1005). The operator goes inside quotes and is joined to the date with &. Using DATE() avoids problems with regional date formats that you can get when typing a date as text.
If your dates also contain times, a safer pattern for a full month is "on or after the 1st and before the 1st of the next month". Here it is combined with a product condition to count laptop orders in February:
=COUNTIFS(D2:D13,"Laptop*",B2:B13,">="&DATE(2026,2,1),B2:B13,"<"&DATE(2026,3,1))
Result: 2 (SO-1006 and SO-1008).
4. Wildcards: partial text matches
COUNTIFS supports two wildcards in text criteria:
*matches any number of characters (including none).?matches exactly one character.
Count shipped orders for any product whose name contains "Pro":
=COUNTIFS(D2:D13,"*Pro*",F2:F13,"Shipped")
Result: 3 (SO-1001, SO-1008 and SO-1011). SO-1006 (Laptop Pro 16) is Cancelled and SO-1009 (Keyboard Pro) is Pending, so they drop out.
The question mark is useful when one character varies:
=COUNTIFS(D2:D13,"Laptop?Pro*")
Result: 3, matching "Laptop Pro 14" twice and "Laptop Pro 16" once. If you need to match a literal asterisk or question mark, put a tilde in front of it (~* or ~?).
5. Number conditions and "not equal to"
Comparison operators work the same way as with dates. Count orders over 500 that were not cancelled:
=COUNTIFS(E2:E13,">500",F2:F13,"<>Cancelled")
Result: 4 (SO-1001, SO-1004, SO-1008 and SO-1012). "<>Cancelled" means "anything except Cancelled". To use a threshold stored in a cell, write ">"&J1.
How it works
COUNTIFS checks every row of the ranges side by side. For row 2 it tests C2 against the first condition, F2 against the second, and so on. Only if all tests pass does that row add 1 to the total. That is why the ranges must all be the same size and shape: row 5 of one range has to line up with row 5 of the others.
Text comparisons are not case-sensitive. In the test sheet, =COUNTIFS(C2:C13,"east",F2:F13,"shipped") returned the same 4 as the capitalized version. If you need a case-sensitive count, use SUMPRODUCT with EXACT instead.
Common mistakes
- Ranges of different sizes.
C2:C13withF2:F12returns a #VALUE! error. Keep every range the same height. - Operator outside the quotes. Write
">="&DATE(2026,1,1), not>="2026-01-01". - Expecting OR logic. Extra pairs in COUNTIFS always narrow the result. Use the addition or SUM({...}) method for OR.
- Double counting with OR across columns. Adding COUNTIFs for conditions in different columns counts overlapping rows twice; use SUMPRODUCT.
- Hidden spaces. "East " with a trailing space won't match "East". Clean the data with TRIM, or use a wildcard like
"East*"as a quick check. - Dates stored as text. If a date range returns 0, check that the dates are real dates (they usually align right by default) and not text.
FAQ
What is the difference between COUNTIF and COUNTIFS?
COUNTIF takes one range and one condition. COUNTIFS takes one or more range/condition pairs and counts rows that meet all of them. COUNTIFS with a single pair gives the same result as COUNTIF.
Does COUNTIFS work in Google Sheets?
Yes. The syntax, operators and wildcards shown here work the same way in Google Sheets. For OR logic, the version that adds two COUNTIFS is the most portable.
Can I use COUNTIFS to count blank or non-blank cells?
Yes. Use "" as the criterion for blank cells and "<>" for non-blank cells, for example =COUNTIFS(F2:F13,"<>").
Summary
COUNTIFS counts rows that meet every condition you list, which covers most AND questions directly. For OR within one column, add COUNTIFS together or use SUM with an array constant; for OR across columns, switch to SUMPRODUCT to avoid double counting. Use ">="&DATE(...) for date ranges and * or ? for partial text. For more counting and summing techniques, browse the Math & Conditional Sums tutorials or the full Excel collection.
Comments
Post a Comment