Sub topic 4
AVERAGEIFS: averaging a range by condition
Assume you can enter Google Sheets formulas, use ranges such as A2:A100, and distinguish text, numbers, and dates. In this chapter, you will average only the values from rows that meet one or more conditions.
What AVERAGEIFS does
AVERAGEIFS calculates the arithmetic mean of selected cells. It includes a value only when its row satisfies every condition.
For example, suppose:
| Region | Product | Units | Revenue |
|---|---|---|---|
| West | Widget A | 12 | 240 |
| East | Widget B | 15 | 300 |
| West | Widget C | 8 | 160 |
| West | Widget D | 20 | 500 |
To average Revenue for rows in the West region:
=AVERAGEIFS(D2:D5, A2:A5, "West")The first argument, D2:D5, is the range to average. The next two arguments form a criteria pair:
A2:A5is the criteria range."West"is the condition.
The matching revenues are 240, 160, and 500, so the result is 300.
Add conditions with AND logic
Each additional criteria pair narrows the rows. A row must satisfy all pairs, which is AND logic.
=AVERAGEIFS(D2:D5, A2:A5, "West", C2:C5, ">=10")This averages Revenue where Region is West and Units are at least 10. Only the rows with revenues 240 and 500 qualify, so the result is 370.
The argument pattern is:
=AVERAGEIFS(average_range, criteria_range1, criterion1, criteria_range2, criterion2)The average range comes first. This differs from some related single-condition functions, so check the argument order when converting a formula.
Avoid range and no-match errors
Every range should cover the same rows. This is unsafe:
=AVERAGEIFS(D2:D100, A2:A99, "West")The ranges have different sizes. Use matching endpoints, such as D2:D100 and A2:A100.
If no row meets the conditions, AVERAGEIFS returns #DIV/0! because it has no numbers to average. Wrap it with IFERROR when a readable result is better:
=IFERROR(AVERAGEIFS($D$2:$D$100, $A$2:$A$100, G2), "No matches")Here, G2 contains the region to search. The dollar signs create absolute references, so the data ranges stay fixed when you fill the formula down.
Exercise
Write a formula that averages Revenue in E2:E100 for rows where Region in A2:A100 is "West" and Units in D2:D100 are at least 10.
Show answer
=AVERAGEIFS(E2:E100, A2:A100, "West", D2:D100, ">=10")