COUNTIFS, SUMIFS and AVERAGEIFS
Answer questions like "how much did the West region sell over $500?" with conditional counts, sums and averages using operators, cells and wildcards.
Welcome back!
Step 1 of 11Learn
Questions a filter can answer once
A sales manager has a table of 4,000 orders and three questions before a 10 a.m. meeting: How many West orders were over $500? What did Ana sell in total? What's the average order in the West?
She could filter the table three times and read the status bar. That works once. Next week the data changes and she does it all again, with no record of what she filtered. Conditional aggregation functions answer the same questions with formulas that update themselves:
COUNTIFScounts rows that meet every condition.SUMIFSadds up a column for rows that meet every condition.AVERAGEIFSaverages a column for those rows.MAXIFSandMINIFSfind the largest and smallest values among them.
We'll use this small table throughout the lesson. Imagine Region in column B, Rep in C and Amount in D, rows 2 to 7:
| Order | Region | Rep | Amount |
|---|---|---|---|
| 1001 | West | Ana | 820 |
| 1002 | East | Ben | 430 |
| 1003 | West | Ana | 310 |
| 1004 | West | Cho | 1,250 |
| 1005 | East | Ana | 990 |
| 1006 | West | Ben | 505 |
The same formulas work identically on 4,000 rows or 400,000.
Step 2 of 11Learn
COUNTIFS and how criteria work
COUNTIFS takes pairs of arguments: a range to check, then the condition for that range.
=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)
To count West orders over $500:
=COUNTIFS(B2:B7, "West", D2:D7, ">500")
Every pair must be satisfied, so multiple conditions are combined with AND logic. All ranges must be the same size, or you get #VALUE!.
Criteria are written as text, which trips people up. An exact match is just the value: "West" or 1001. A comparison puts the operator inside the quotes: ">500", "<=100", "<>East" (not East).
When the threshold lives in a cell, say F1, you can't write ">F1", because that's a comparison with the literal text F1. Instead, join the operator to the cell with &:
=COUNTIFS(D2:D7, ">"&F1)
The single-condition version, COUNTIF(range, criteria), still works, but since COUNTIFS handles one condition just as well, many people use the plural form everywhere.
Step 3 of 11Practice · Work it out
Using the order table, what does =COUNTIFS(B2:B7, "West", D2:D7, ">500") return?
Step 4 of 11Learn
SUMIFS, AVERAGEIFS and the argument-order trap
SUMIFS and AVERAGEIFS add one argument at the front: the range to sum or average.
=SUMIFS(sum_range, criteria_range1, criteria1, ...)
Ana's total sales:
=SUMIFS(D2:D7, C2:C7, "Ana") returns 820 + 310 + 990 = 2,120.
Average West order:
=AVERAGEIFS(D2:D7, B2:B7, "West") returns (820 + 310 + 1,250 + 505) / 4 = 721.25.
Largest East order: =MAXIFS(D2:D7, B2:B7, "East") returns 990.
Now the trap. The older single-condition SUMIF puts the sum range last:
=SUMIF(C2:C7, "Ana", D2:D7)
People who learned SUMIF first often write SUMIFS in the old order. Excel then tries to sum the Rep column (which is text, so it returns 0) or returns #VALUE!. If a conditional sum comes back as 0 when you know there's data, check the argument order first.
One more caution: AVERAGEIFS returns #DIV/0! when no rows match, since it would be dividing by zero rows.
Step 5 of 11Compare
SUMIF vs SUMIFS: the argument-order trap
| Aspect | SUMIF | SUMIFS |
|---|---|---|
| Syntax | SUMIF(range, criteria, [sum_range]) | SUMIFS(sum_range, range1, criteria1, ...) |
| Where the sum range goes | Last | First |
| Ana's total | =SUMIF(C2:C7, "Ana", D2:D7) | =SUMIFS(D2:D7, C2:C7, "Ana") |
| Number of conditions | One | One or many (AND logic) |
| Symptom of mixing them up | Wrong total | Result of 0 or #VALUE! |
Step 6 of 11Practice · Choose one
Which formula correctly totals the Amount column (D) for East orders by Ben?
Step 7 of 11Learn
Wildcards, blanks and date ranges
Text criteria can include wildcards:
*matches any number of characters:"*phone*"matches "Smartphone", "phone case" and "Headphones".?matches exactly one character:"A-??"matches "A-10" and "A-7B" but not "A-100".~escapes a real asterisk or question mark:"~*"matches an actual*.
Wildcards only work on text. They don't match numbers stored as numbers.
To test for empty or non-empty cells: "" matches blank cells and "<>" matches cells that aren't blank. =COUNTIFS(E2:E500, "<>") counts rows where a ship date has been entered.
Date ranges use two conditions on the same column. Sales in March 2026, with start and end dates in H1 and H2:
=SUMIFS(D:D, A:A, ">="&H1, A:A, "<="&H2)
Putting the dates in cells beats typing them into the formula: ">=3/1/2026" depends on regional date settings, while a real date in a cell always works. Better still, use ">="&H1, "<"&EDATE(H1,1), which captures the whole month even when times are attached to the dates.
Step 8 of 11Practice · Match the pairs
Match each criteria argument to what it matches.
Tap an answer, then tap the place where it belongs (or drag it there).
- ">=100"
- "<>Closed"
- "tea"
- "<>"
- ">"&F1
Step 9 of 11Note
Step 10 of 11Practice · Work it out
Using the order table, what does =AVERAGEIFS(D2:D7, C2:C7, "Ana", B2:B7, "West") return?
Step 11 of 11Practice · Spot the mistake
This formula should total column D for West orders at or above the threshold in F1, but it returns 0. Click the faulty argument.
Lesson complete!