Syntax, a live playground, a measured criteria gallery, the #DIV/0! no-match trap, and a sourced error library: conditional averages.
Averages the cells that meet one criteria. Returns #DIV/0! when nothing matches — guard it with IFERROR.
AVERAGEIF averages only the cells that meet one criteria. The surprise is the no-match case: it is an error, not zero. Every row was measured live in HyperFormula. Click any row to load it.
| Expression | Result | Why |
|---|---|---|
| =AVERAGEIF(A2:A5,"Apple",B2:B5) | 125 | (100+150)/2 |
| =AVERAGEIF(B2:B5,">150") | 250 | 2-arg: average the range itself where >150 |
| =AVERAGEIF(D2:D5,"East",B2:B5) | 125 | East amounts averaged |
| =AVERAGEIF(A2:A5,"Banana",B2:B5) | 200 | A single matching row |
| =AVERAGEIF(A2:A5,"<>Apple",B2:B5) | 250 | Not-Apple: (200+300)/2 |
| =AVERAGEIF(A2:A5,"Apple",C2:C5) | 12.5 | Average the qty column instead |
| =AVERAGEIF(B2:B5,"<200") | 125 | Below 200: (100+150)/2 |
| =AVERAGEIF(A2:A5,"Missing",B2:B5) | #DIV/0! | No match: divide by zero |
| Expression | Result | Why |
|---|---|---|
| =AVERAGEIF(range, criteria) | averages range | 2-arg: test and average the same range |
| =AVERAGEIF(range, criteria, average_range) | averages average_range | 3-arg: test one range, average another |
Edit the table or type any formula — the engine evaluates instantly. Load a preset to see AVERAGEIF average a cross-column range, use the 2-arg form, and hit the #DIV/0! no-match case.
8 failure patterns mined from actual user reports on Reddit, Stack Overflow and Super User — each with the authentic symptom, root cause, a fix, and a runnable formula. Not textbook theory.
AVERAGEIF is available across modern Excel, Google Sheets and LibreOffice. It has been in Excel since 2007.
| Platform | Support | Notes | Gotcha |
|---|
AVERAGEIF is one piece. The full course walks the toolkit end to end with live, measured examples.