Statistical function

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])
ArgumentWhat it means
rangeRequiredThe cells to test against the condition.
criteriaRequiredThe condition: a number (100), text ("North"), a comparison in quotes (">1000"), wildcards ("Laptop*") or a cell joined to an operator (">="&E1).
average_rangeOptionalThe 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

D2fx=AVERAGEIF(A2:A7, "North", B2:B7)
ABCD
1RegionOrder value
2North12001,400
3South950
4North1650
5East800
6North1350
7South1100

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

D2fx=AVERAGEIF(B2:B7, ">1000")
ABCD
1RegionOrder value
2North12001,325
3South950
4North1650
5East800
6North1350
7South1100

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

D2fx=AVERAGEIF(A2:A6, "Laptop*", B2:B6)
ABCD
1ProductPrice
2Laptop Pro 141299982.33
3Laptop Air 13999
4Wireless mouse25
5Laptop Basic 15649
6Keyboard45

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

D2fx=AVERAGEIF(B2:B7, "<>0")
ABCD
1WeekShop sales
21520550
320
43610
54480
650
76590

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.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 18 KB

Common errors and how to fix them

ErrorWhy it happensFix
#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.

LanguageFunction name
DanishMIDDEL.HVIS
DutchGEMIDDELDE.ALS
FinnishKESKIARVO.JOS
FrenchMOYENNE.SI
GermanMITTELWERTWENN
HungarianÁTLAGHA
ItalianMEDIA.SE
Norwegian (Bokmål)GJENNOMSNITTHVIS
PolishŚREDNIA.JEŻELI
Portuguese (Brazil)MÉDIASE
Portuguese (Portugal)MÉDIA.SE
RussianСРЗНАЧЕСЛИ
SpanishPROMEDIO.SI
SwedishMEDEL.OM
TurkishEĞERORTALAMA

Recipes that use AVERAGEIF