COUNTIF, SUMIF and SUMIFS
Count and total only the rows that meet your conditions with COUNTIF, SUMIF, AVERAGEIF, COUNTIFS and SUMIFS, using text, number and date criteria.
Welcome back!
Step 1 of 12Learn
Count only what matches
A store manager has 2,000 order rows and three questions: How many orders came from the West region? How many were over $100? How many are still unpaid? Sorting and counting by eye would take an afternoon. COUNTIF answers each in one formula:
=COUNTIF(range, criteria)
=COUNTIF(B2:B2001, "West")counts cells equal to West.=COUNTIF(D2:D2001, ">100")counts amounts over 100.=COUNTIF(E2:E2001, "<>Paid")counts everything not equal to Paid.
The criteria is written as text in quotes, including comparison operators: ">100", "<=0", "<>Paid". A plain number such as 5 can go without quotes.
Criteria are not case sensitive, so "west", "West" and "WEST" all match. They do care about stray spaces: "West " with a trailing space will not match "West". Imported data often hides such spaces, which you'll learn to remove with TRIM in Module 4.
Wildcards help with partial text: an asterisk (*) stands for any number of characters, and a question mark (?) for exactly one. "*phone*" matches iPhone case, Phone stand and headphones; "A???" matches any four-character text starting with A. Divide one count by another to get a share: =COUNTIF(E2:E2001, "Paid")/COUNTA(E2:E2001) gives the percentage of paid orders.
Step 2 of 12Learn
Totals with a condition: SUMIF and AVERAGEIF
Counting tells you how many; often you need how much. SUMIF adds the values in one column for the rows where another column meets a condition:
=SUMIF(range, criteria, [sum_range])
=SUMIF(B2:B2001, "West", D2:D2001)adds the amounts in D for every row where B is West.=SUMIF(D2:D2001, ">100")adds the amounts that are themselves over 100; when the test column and the sum column are the same, sum_range can be left out.
AVERAGEIF has the same arguments and returns the average instead: =AVERAGEIF(B2:B2001, "West", D2:D2001) is the average West order.
Worked example with five orders:
| Region (B) | Amount (D) |
|---|---|
| West | 120 |
| East | 80 |
| West | 45 |
| North | 200 |
| West | 35 |
=SUMIF(B2:B6, "West", D2:D6) = 120 + 45 + 35 = 200. =COUNTIF(B2:B6, "West") = 3. =AVERAGEIF(B2:B6, "West", D2:D6) = 200 / 3 ≈ 66.67.
Make sure the range and sum_range are the same size and start on the same row. If one starts at row 2 and the other at row 3, every value is paired with the wrong row and the total is quietly wrong, with no error to warn you.
Step 3 of 12Practice · Work it out
Using the five-order table from the lesson (West 120, East 80, West 45, North 200, West 35), what does =SUMIF(D2:D6, ">50") return?
Step 4 of 12Practice · Chart
SUMIF by region for the five-order table
Which region's total is built from three separate orders?
Tap the bar that answers the question, then press Check.
Step 5 of 12Learn
Several conditions: SUMIFS and COUNTIFS
When there's more than one condition, use the plural versions. COUNTIFS and SUMIFS include a row only if it meets all the conditions (like AND):
=COUNTIFS(range1, criteria1, range2, criteria2, …)
=SUMIFS(sum_range, range1, criteria1, range2, criteria2, …)
Watch the argument order: in SUMIFS, the sum range comes first, while in SUMIF it comes last. Mixing them up is the most common SUMIFS error.
- Laptop sales in the West:
=SUMIFS(D2:D2001, B2:B2001, "West", C2:C2001, "Laptop") - Orders between $100 and $500:
=COUNTIFS(D2:D2001, ">=100", D2:D2001, "<=500"). The same column can appear twice for a range.
Criteria from cells. Rather than typing "West" into the formula, point to a cell, so one formula can be copied down a summary table: =SUMIFS($D$2:$D$2001, $B$2:$B$2001, G2). For a comparison, join the operator to the cell with an ampersand: ">"&H1 means "greater than whatever H1 holds". Writing ">H1" in quotes would look for text greater than the letters H1.
Dates work the same way: =COUNTIFS(A2:A2001, ">="&DATE(2026,1,1), A2:A2001, "<"&DATE(2026,2,1)) counts January 2026 orders. Using "<" the first of next month safely includes every January date, even those with times attached.
Step 6 of 12Compare
SUMIF vs SUMIFS
| Aspect | SUMIF | SUMIFS |
|---|---|---|
| Conditions | One | One or more (all must be met) |
| Sum range position | Last (optional) | First (required) |
| Example | =SUMIF(B:B, "West", D:D) | =SUMIFS(D:D, B:B, "West", C:C, "Laptop") |
| Counting version | COUNTIF | COUNTIFS |
Step 7 of 12Practice · Choose one
Amounts are in D2:D500, regions in B2:B500 and products in C2:C500. Which formula totals amounts for region "East" and product "Chair"?
Step 8 of 12Tap to reveal
Criteria cheat sheet
Exact text: "West"
Matches cells equal to West, ignoring case. A trailing space in the data breaks the match.
Comparison: ">100", "<=0", "<>Paid"
Operator and value go inside the same quotes. <> means not equal to.
Wildcards:
"*phone*", "INV-???"- matches any number of characters; ? matches exactly one.
"*phone*"means contains phone.
- matches any number of characters; ? matches exactly one.
Blank and not blank: "" and "<>"
"" counts empty cells; "<>" counts cells that are not empty.
Cell reference: G2 or ">"&H1
Point to a cell for flexible criteria. Join an operator to a cell with &; never put the cell address inside quotes.
Dates: ">="&DATE(2026,1,1)
Build dates with DATE(year, month, day) or point to a date cell, so regional date formats cannot confuse Excel.
Step 9 of 12Practice · Match the pairs
Match each COUNTIF criteria to what it counts.
Tap an answer, then tap the place where it belongs (or drag it there).
- "<>Closed"
"*tax*"- ">="&F1
- ""
- "<0"
Step 10 of 12Learn
Building a summary table
The real payoff of conditional functions is a small summary that updates itself. Picture a data sheet with 2,000 orders and a summary sheet like this:
| G (Region) | H (Orders) | I (Revenue) | J (Avg order) | |
|---|---|---|---|---|
| 2 | West | =COUNTIFS(Data!$B:$B, G2) | =SUMIFS(Data!$D:$D, Data!$B:$B, G2) | =I2/H2 |
| 3 | East | (copied) | (copied) | (copied) |
| 4 | North | (copied) | (copied) | (copied) |
Write row 2 once with the data ranges locked, copy it down, and you have a live report. Add a "month" cell and a second condition, and the whole table filters by month when you change one cell.
Two checks keep these tables honest. First, the totals of the summary should match the total of the raw data: =SUM(I2:I4) should equal =SUM(Data!D:D). If it doesn't, some rows have a region you didn't list, often a typo such as "Wset" or a stray space. Second, guard against dividing by a zero count with =IF(H2=0, "", I2/H2).
This approach is perfect for a fixed, small set of categories. When you need to slice by many fields at once, a PivotTable (Module 5) does the same job with dragging instead of formulas.
Step 11 of 12Practice · True or false
=COUNTIF(B2:B100, "west") will not count cells that contain "West" with a capital W.
Step 12 of 12Practice · Work it out
A list has these order amounts: 90, 150, 300, 520, 410 and 75. What does =COUNTIFS(D2:D7, ">=100", D2:D7, "<=500") return?
Lesson complete!