
The AVERAGEIF function in Excel calculates the average of the numbers that meet one condition, such as the average sale in one region or the average score above 50. This guide explains the syntax and gives AVERAGEIF examples with made-up data: a text condition, a number condition, wildcards, a different average range and what to do with several conditions using AVERAGEIFS.
AVERAGEIF syntax
=AVERAGEIF(range, criteria, [average_range])
- range is the cells Excel tests.
- criteria is the condition, like "North" or ">100".
- average_range is the cells to average. If you leave it out, Excel averages the cells in the first range.
Average by a text condition
Say A2:A8 holds regions and B2:B8 holds sales. To get the average sale in the North region:
=AVERAGEIF(A2:A8, "North", B2:B8)
With the made-up North sales of 100, 60 and 80, the result is 80.

Average numbers above a value
Put the operator inside quotes. To average only the values above 50 in B2:B8:
=AVERAGEIF(B2:B8, ">50")
When the limit sits in a cell, join it with an ampersand: =AVERAGEIF(B2:B8, ">" & E1).

Average with a wildcard
An asterisk stands for any characters. To average the sales of every product with "desk" in its name:
=AVERAGEIF(A2:A8, "*desk*", B2:B8)
Average everything except one item
=AVERAGEIF(A2:A8, "<>North", B2:B8)
Ignore zeros
A normal average counts zeros. To leave them out:
=AVERAGEIF(B2:B8, "<>0")
Handle the #DIV/0! error
If no cell matches the condition, AVERAGEIF returns #DIV/0! because there is nothing to average. Show a message instead:
=IFERROR(AVERAGEIF(A2:A8, "East", B2:B8), "No data")
Read our guide to the IFERROR function before you use this on all formulas, because it can hide real mistakes.

More than one condition: AVERAGEIFS
AVERAGEIF accepts one condition. For several, use AVERAGEIFS, where the average range comes first:
=AVERAGEIFS(B2:B8, A2:A8, "North", B2:B8, ">50")
This averages the North sales that are above 50. The idea is the same as in COUNTIFS with multiple criteria.

Related functions
To add instead of average, see the SUMIF function. For a weighted average, which needs each value multiplied by a weight, use SUMPRODUCT.
Common mistakes
- Numbers stored as text. Excel ignores them, so the average is wrong or an error.
- Empty and text cells. AVERAGEIF ignores empty cells and text in the average range.
- Missing quotes. Operators and text must be in quotation marks.
- Different range sizes. Keep the range and the average range the same shape.
Questions and answers
Does AVERAGEIF work in Google Sheets?
Yes, with the same arguments.
Is AVERAGEIF case sensitive?
No. "north" and "North" give the same result.
How do I average the top 3 values?
Use AVERAGE with LARGE: =AVERAGE(LARGE(B2:B8, {1,2,3})).
What is the difference between AVERAGE and AVERAGEIF?
AVERAGE uses every number in the range. AVERAGEIF uses only the numbers that meet your condition.
Summary
Use AVERAGEIF with a range, a condition in quotes and an optional average range. Move to AVERAGEIFS for several conditions and wrap the formula in IFERROR when a condition can match nothing.
