Sub topic 4
AVERAGEIFS: averaging a range by condition
This chapter assumes you can enter formulas in Google Sheets and read ranges such as E2:E100. It also assumes you know AVERAGE and the difference between text, numbers, and dates in cells. It builds on the previous two chapters, so you should know how COUNTIFS and SUMIFS pair a range with a criterion.
What AVERAGEIFS does
AVERAGEIFS returns the arithmetic mean of the values in one range, using only the rows where every condition is true. It answers questions such as "What is the average revenue per West-region sale?" or "What is the average order size for orders of at least 10 units?"
The syntax is:
=AVERAGEIFS(average_range, criteria_range1, criterion1, [criteria_range2, criterion2, ...])average_rangeis the column of numbers you want to average. It comes first.- Each
criteria_rangeandcriterionpair is one condition. The first pair is required. More pairs are optional.
Putting the range to average first is the same convention as SUMIFS. It differs from COUNTIFS, which has no value range at all. If you write the arguments in the wrong order, the formula often returns #DIV/0! or a wrong number, with no other warning.
A working example
The examples use this sample data in A1:E6. Row 1 holds the headers.
| Row | A: Region | B: Product | C: Date | D: Units | E: Revenue |
|---|---|---|---|---|---|
| 2 | West | Widget | 2026-01-05 | 12 | 240 |
| 3 | West | Gadget | 2026-01-09 | 4 | 100 |
| 4 | East | Widget | 2026-01-12 | 10 | 200 |
| 5 | West | Widget | 2026-02-02 | 8 | 160 |
| 6 | East | Gadget | 2026-02-10 | 15 | 375 |
To average revenue for the West region:
=AVERAGEIFS(E2:E6, A2:A6, "West")The West rows are 2, 3, and 5. Their revenues are 240, 100, and 160. The sum is 500 and the count is 3, so the result is 166.67 (rounded for display).
Matching is not case-sensitive, so "west" and "WEST" give the same result.
How the function evaluates
Sheets does not filter the table and then average it. It checks each row against all the conditions and keeps a running sum and count of the qualifying values.
Two consequences follow from this model.
- Every criteria pair must be true for a row to count. Conditions combine with AND.
- A row can match all the criteria and still be skipped, if its
average_rangecell is blank or contains text.
Adding a second condition
Each extra condition is another pair of arguments. To average revenue for West rows with at least 10 units:
=AVERAGEIFS(E2:E100, A2:A100, "West", D2:D100, ">=10")Applied to the sample range, only row 2 is West with 12 units, so the result is 240. Rows 3 and 5 are West but have fewer than 10 units. Rows 4 and 6 have enough units but are East.
The comparison operator and the number sit together inside one quoted string, ">=10". The chapter on comparison operators covers the operators in detail. For now, remember that a bare 10 means "equals 10" and ">=10" means "10 or more".
The blank-cell gotcha: AVERAGEIFS is not SUMIFS divided by COUNTIFS
It is natural to assume the average equals the sum divided by the count:
=SUMIFS(E2:E100, A2:A100, "West") / COUNTIFS(A2:A100, "West")This is only equal to AVERAGEIFS when every matching row has a number in the average range. Suppose a West row has an empty Revenue cell:
COUNTIFSstill counts that row, because it only looks at the Region column.AVERAGEIFSleaves it out of both the sum and the count.
So the division gives a lower value than AVERAGEIFS. Which one is correct depends on what an empty cell means in your data. If a blank means "no data yet", AVERAGEIFS is correct. If a blank should count as zero revenue, enter an actual 0 in the cell or use the division form.
The same rule applies to text in the average range. A cell containing "n/a" or "pending" is skipped silently. A zero is a number, so it is included and pulls the average down.
> Numbers that were pasted or imported as text look like numbers but are ignored by AVERAGEIFS. If an average looks too high or the formula returns #DIV/0! on data that clearly exists, check that the cells are right-aligned or use =ISNUMBER(E2) to test them.
The average of averages trap
When you build a table with one AVERAGEIFS per region, do not average those results to get an overall figure. Using the sample data, West averages 166.67 and East averages 287.5. The mean of those two is 227.08. The true overall average across all five rows is (240 + 100 + 200 + 160 + 375) / 5 = 215. The two figures differ because West has three rows and East has two. To get the overall figure, use =AVERAGE(E2:E6), or sum all revenue and divide by the total count.
What happens when nothing matches
If no row meets all the conditions, the count is zero and the division fails:
=AVERAGEIFS(E2:E6, A2:A6, "North")This returns #DIV/0!. The error is not a sign that your syntax is broken. It means "no qualifying rows". A later chapter shows how to replace it with a readable message using IFERROR. Here is the preview, with absolute references so the formula can be filled down a summary table:
=IFERROR(AVERAGEIFS($E$2:$E$100, $A$2:$A$100, G2), "No matches")Use IFERROR with care. It hides every error, including real ones such as range-size mismatches. Test the plain formula first, then add the wrapper.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| `#DIV/0!` when data clearly exists | The `average_range` cells are text, or a criterion has a typo such as a trailing space | Check with `ISNUMBER`, and compare the criterion text with the cell text |
| `#VALUE!` | Range sizes differ, for example `E2:E100` with `A2:A99` | Make every range the same height (a later chapter covers this) |
| Average is unexpectedly high or low | Blanks, text, or placeholder zeros in the average range | Review how blanks and zeros are stored |
| Result is wrong, with no error | Arguments in the wrong order, so a criteria range was used as the average range | Put the range to average first |
| Condition is ignored | The operator is outside the quotes, as in `>=10` instead of `">=10"` | Put the operator and the value in one quoted string |
Choosing between AVERAGEIFS and other approaches
- Use
AVERAGEIFSwhen you need one number for a defined subset and want the formula to update as data changes. - Use
AVERAGEon a filtered view only if you accept that filtered-out rows are still counted, becauseAVERAGEdoes not respect filters. - Use a pivot table when you want averages for every group without writing a formula for each one.
Next, the chapter on criteria pairs and AND logic covers several conditions in more depth. The chapter on wildcards then covers partial text matches.
Exercise
Using the sample data in A1:E6 (Region, Product, Date, Units, Revenue), write a formula for the average revenue of Widget sales in the East region. Then say what result it returns and what it returns for Gadget sales in the West region with at least 10 units.
Show answer
The formula is =AVERAGEIFS(E2:E6, A2:A6, "East", B2:B6, "Widget"). Only row 4 is East and Widget, so it returns 200. For West Gadget sales with at least 10 units, the formula =AVERAGEIFS(E2:E6, A2:A6, "West", B2:B6, "Gadget", D2:D6, ">=10") matches no row: the only West Gadget row has 4 units. The count is zero, so it returns #DIV/0!.
Exercise
A West row has an empty Revenue cell, and nine other West rows have numbers that add up to 900. What does AVERAGEIFS return for West revenue, and what does SUMIFS divided by COUNTIFS return? Why do they differ?
Show answer
AVERAGEIFS returns 100, because it skips the empty Revenue cell and divides 900 by 9. SUMIFS divided by COUNTIFS returns 90, because COUNTIFS counts all 10 West rows by Region alone and 900 is divided by 10. They differ because COUNTIFS ignores the value range, while AVERAGEIFS leaves out rows whose average_range cell is blank or text.