AVERAGEIF function
Averages only the cells that meet one condition, such as all orders from one region or all invoices above a certain amount.
Available in Excel 2007 and later, Excel for the web, Excel for Mac
Excel 2007 and laterWorks in Google Sheets
Syntax
AVERAGEIF(range, criteria, [average_range])| Argument | What it means | |
|---|---|---|
range | Required | The cells to test against the condition. |
criteria | Required | The condition: a number (100), text ("North"), a comparison in quotes (">1000"), wildcards ("Laptop*") or a cell joined to an operator (">="&E1). |
average_range | Optional | The cells to average. If omitted, the cells in range are averaged. It should be the same size and shape as range. |
Returns: The mean of the matching cells, or #DIV/0! if nothing matches.
How AVERAGEIF works
AVERAGEIF combines a filter and an average in a single step. You tell it which cells to test, what the test is, and (optionally) which cells to average. Only the rows that pass the test are included. It is the go-to function for questions such as "what is the average order value in the North region?" or "what is the average invoice above €1,000?"
The criteria work the same way as in COUNTIF and SUMIF. Text matching is not case-sensitive, * stands for any run of characters and ? for a single character. Comparisons must be written as text, so you type ">1000" with quotes; to compare with a value in a cell, glue the operator and the cell together with &, as in ">="&E1. Inside the average range, blanks and text are ignored just like in AVERAGE.
If you need two or more conditions (region and product, or a date range), use AVERAGEIFS, which also puts the average range first. When no cell meets the condition AVERAGEIF returns #DIV/0!, which you can catch with IFERROR.
Examples
1Average order in the North region
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Region | Order value | ||
| 2 | North | 1200 | 1,400 | |
| 3 | South | 950 | ||
| 4 | North | 1650 | ||
| 5 | East | 800 | ||
| 6 | North | 1350 | ||
| 7 | South | 1100 |
Result: 1,400
Three rows have North in column A (1,200, 1,650 and 1,350). Their total is 4,200, and 4,200 / 3 = 1,400.
2Average of orders above 1,000
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Region | Order value | ||
| 2 | North | 1200 | 1,325 | |
| 3 | South | 950 | ||
| 4 | North | 1650 | ||
| 5 | East | 800 | ||
| 6 | North | 1350 | ||
| 7 | South | 1100 |
Result: 1,325
When the test and the average use the same column you can leave out average_range. Four orders exceed 1,000 (1,200, 1,650, 1,350 and 1,100); their mean is 5,300 / 4 = 1,325.
3Wildcard: all laptop models
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Product | Price | ||
| 2 | Laptop Pro 14 | 1299 | 982.33 | |
| 3 | Laptop Air 13 | 999 | ||
| 4 | Wireless mouse | 25 | ||
| 5 | Laptop Basic 15 | 649 | ||
| 6 | Keyboard | 45 |
Result: 982.33
Laptop* matches any product name that starts with "Laptop". The three laptops cost 2,947 in total, so the average price is 982.33 (shown with 2 decimals).
4Average without the zero weeks
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Week | Shop sales | ||
| 2 | 1 | 520 | 550 | |
| 3 | 2 | 0 | ||
| 4 | 3 | 610 | ||
| 5 | 4 | 480 | ||
| 6 | 5 | 0 | ||
| 7 | 6 | 590 |
Result: 550
The shop was closed in weeks 2 and 5, so those zeros would make normal trading look worse than it was. "<>0" means "not equal to zero", leaving (520 + 610 + 480 + 590) / 4 = 550. A plain AVERAGE would return about 366.67.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#DIV/0! | No cell meets the condition, or all matching cells in average_range are blank or text. | Check the spelling of the criteria and extra spaces in the data, or wrap the formula: =IFERROR(AVERAGEIF(...), 0). |
Wrong result (no error) | average_range is a different size from range. Excel silently resizes it from its top-left cell, which can shift the rows. | Make both ranges exactly the same height, e.g. A2:A7 and B2:B7. |
Tips
- To test for a real asterisk or question mark, put a tilde in front:
"~*". - Dates in criteria work best when built with DATE:
">="&DATE(2026,1,1). - AVERAGEIF needs a real range as its first argument, not an array created by another formula. If you need that, use
=AVERAGE(FILTER(...))in Microsoft 365.
Questions
Is AVERAGEIF case-sensitive?
No. "north", "North" and "NORTH" all match. For a case-sensitive average, use =AVERAGE(IF(EXACT(A2:A7, "North"), B2:B7)).
How do I use a cell value as the criterion?
Type the value in a cell, say E1, and write =AVERAGEIF(A2:A7, E1, B2:B7). For comparisons, join the operator: =AVERAGEIF(B2:B7, ">"&E1).
Can AVERAGEIF ignore blank cells in the test range?
Yes, use the criterion "<>", which matches any non-empty cell, e.g. =AVERAGEIF(A2:A7, "<>", B2:B7).
Google Sheets
AVERAGEIF also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
AVERAGEIF in other languages
In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.
| Language | Function name |
|---|---|
| Danish | MIDDEL.HVIS |
| Dutch | GEMIDDELDE.ALS |
| Finnish | KESKIARVO.JOS |
| French | MOYENNE.SI |
| German | MITTELWERTWENN |
| Hungarian | ÁTLAGHA |
| Italian | MEDIA.SE |
| Norwegian (Bokmål) | GJENNOMSNITTHVIS |
| Polish | ŚREDNIA.JEŻELI |
| Portuguese (Brazil) | MÉDIASE |
| Portuguese (Portugal) | MÉDIA.SE |
| Russian | СРЗНАЧЕСЛИ |
| Spanish | PROMEDIO.SI |
| Swedish | MEDEL.OM |
| Turkish | EĞERORTALAMA |