Conditional function
Excel AVERAGEIF function
AVERAGEIF averages the numbers in rows that meet one condition. Use it for the average score of one class, the average ticket in one category, or to average while ignoring zeros.
=AVERAGEIF(range, criteria, [average_range])Arguments
range- The cells to test against the condition.
criteria- The condition, like "Math" or ">0". Text and operators go in quotes.
average_range- Optional. The cells to average. Leave it out to average the range itself.
AVERAGEIF examples
Every result below was calculated live from this sample sheet.
| A | B | C | |
|---|---|---|---|
| 1 | Student | Subject | Score |
| 2 | Liam | Math | 82 |
| 3 | Liam | Science | 74 |
| 4 | Zoe | Math | 91 |
| 5 | Zoe | Science | 0 |
| 6 | Noah | Math | 68 |
| 7 | Noah | Science | 88 |
Result: 80.333333333
The average Math score across all three students.
Result: 80.6
Zoe's 0 is a missing test. ">0" averages only real scores.
Result: 45.5
Zoe's average, including the 0, which drags it down.
Result: #DIV/0!
No rows match "Art", so there is nothing to average and you get #DIV/0!.
How to use AVERAGEIF
- Click an empty cell.
- Type =AVERAGEIF( and select the column to test.
- Type a comma and the condition in quotes.
- Type a comma and select the column to average.
- Close the bracket and press Enter.
Common AVERAGEIF mistakes
No matching rows
If nothing meets the condition, AVERAGEIF returns #DIV/0!. Wrap it in IFERROR to show a blank or message.
Zeros counted as scores
Zeros are included in the average. Use a criteria like ">0", or switch to AVERAGEIFS to add that as a second condition.
Mixing up argument order with AVERAGEIFS
AVERAGEIF puts average_range last. AVERAGEIFS puts it first.
AVERAGEIF FAQ
How do I average excluding zeros in Excel?
Use =AVERAGEIF(range,"<>0"), or ">0" if you also want to skip negatives.
Why does AVERAGEIF return #DIV/0!?
No cells met the condition, or the matching cells hold no numbers. Check the spelling of your criteria.
Does AVERAGEIF ignore blank cells?
Yes. Blank cells in the average range are skipped and do not count as zeros.
Practice AVERAGEIF in these lessons
Guides that use AVERAGEIF
Related functions
AVERAGEIFSAverages with several conditionsAVERAGEMean of numbersSUMIFAdds cells that matchCOUNTIFCounts cells that match
Updated 2026-10-31