The AVERAGEIF function
AVERAGEIF works like SUMIF, but finds the mean of the matching rows instead of the total. Use it to compare groups: average spend per category, average score per class, or average days to deliver per courier.
Blank cells in the average range are skipped, just as they are in AVERAGE.
=AVERAGEIF(range, criteria, [average_range])
Arguments
- range
- The cells to test against the condition.
- criteria
- The condition: a value like "Swift", a cell, or a comparison like ">=4".
- average_rangeoptional
- The cells to average. Leave it out to average
rangeitself.
Try it
=AVERAGEIF(A2:A7,"Swift",B2:B7) in D2. Swift made three deliveries taking 2, 3 and 1 days, so the average is 6 ÷ 3 = 2 days.
D2
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Courier | Days to deliver | Swift average | ||
| 2 | Swift | 2 | 2 | ||
| 3 | Parcelpoint | 4 | |||
| 4 | Swift | 3 | |||
| 5 | Hedgehog | 6 | |||
| 6 | Parcelpoint | 5 | |||
| 7 | Swift | 1 | |||
| 8 | |||||
| 9 |
Edit the formula in D2, or change the data, and press Enter.
More examples
| Formula | Result | What it does |
|---|---|---|
| =AVERAGEIF(A2:A7,"Parcelpoint",B2:B7) | 4.5 | Two deliveries: (4 + 5) ÷ 2. |
| =AVERAGEIF(B2:B7,">=4") | 5 | With no average range, it averages the tested cells: the slow deliveries only. |
| =AVERAGEIF(A2:A7,"<>Swift",B2:B7) | 5 | Every courier except Swift. |
| =AVERAGEIF(A2:A7,"Rapido",B2:B7) | #DIV/0! | Nothing matched, so there's nothing to average. |
Tips
- For more than one condition, use AVERAGEIFS. Like SUMIFS, it takes the average range first.
- Wrap it in IFERROR to show a dash when a group has no rows yet:
=IFERROR(AVERAGEIF(…),"-"). - Round the result if it feeds a report:
=ROUND(AVERAGEIF(…),1).
Common mistakes
- #DIV/0! appears.No rows matched. Check the spelling of the condition, or for spaces at the end of the names in the data.
- The average looks too low.Zeros are counted. If a 0 means "not done yet", leave those cells blank instead.
- The wrong numbers are averaged.
rangeandaverage_rangemust start on the same row and be the same size.
Practise AVERAGEIF with instant feedback
Type real formulas into a working spreadsheet and get told straight away whether they work.