AVERAGEIF and AVERAGEIFS examples: one condition or several, and why you get #DIV/0!
Two functions with nearly the same name and their arguments in a different order. On a charity shop's real sheet you'll see when to use which, and where an average can lead you astray.
Christophe, founder of Lurndo
· 7 min read
AVERAGEIF takes the average of the numbers that meet one condition, as in =AVERAGEIF(B2:B16,"Clothing",C2:C16). For several conditions, use AVERAGEIFS, with the average range first: =AVERAGEIFS(C2:C16,B2:B16,"Clothing",E2:E16,"Sophie"). If no row fits, both return #DIV/0!, because there's nothing to average. Use ">0" to leave zeros out of it.

What do AVERAGEIF and AVERAGEIFS do?
AVERAGEIF takes the average of the numbers that meet one condition, AVERAGEIFS of the numbers that meet all your conditions. =AVERAGEIF(B2:B16,"Clothing",C2:C16) returns £7.67, the average price of an item of clothing. In a Dutch copy of Excel, the functions are called GEMIDDELDE.ALS and GEMIDDELDEN.ALS.
Every example uses a week of sales at the Second Chance charity shop in Gloucester, the fourth client in our Excel course. If you'd rather learn it step by step, follow the lesson on averages with a condition. If you're after the plain average, a weighted average or how AVERAGE itself works, read how to calculate an average. This article is about the versions with a condition.
How do you write AVERAGEIF and AVERAGEIFS?
=AVERAGEIF(range,criteria,[average_range])
=AVERAGEIFS(average_range,criteria_range1,criteria1,[criteria_range2,criteria2],…)| AVERAGEIF | AVERAGEIFS | |
|---|---|---|
| Conditions | One | One or more, up to 127 |
| Numbers go | Last, optional | First, required |
| Unequal ranges | Excel takes a block in the shape of the range | #VALUE! |
| TRUE or FALSE in the range | Ignored | TRUE counts as 1, FALSE as 0 |
With Dutch or Belgian regional settings you'd write =GEMIDDELDE.ALS(B2:B16;"Clothing";C2:C16) and =GEMIDDELDEN.ALS(C2:C16;B2:B16;"Clothing";E2:E16;"Sophie"). If you copy a formula, translate the function name and the separators.
How do you calculate an average per category?
Coordinator Yasmina at Second Chance wants to know what an item of clothing costs on average, and whether that's more than household goods. This is the whole sheet, with all fifteen sales. G2 holds a price limit of £10.
| Row | A: Item | B: Category | C: Price (£) | D: Day | E: Volunteer |
|---|---|---|---|---|---|
| 2 | Dress green | Clothing | 12 | Mon | Sophie |
| 3 | Book fiction | Books | 2 | Mon | Omar |
| 4 | Lamp | Household | 8 | Tue | Sophie |
| 5 | T-shirt S | Clothing | 3 | Tue | Grace |
| 6 | Dressing gown | Clothing | 6 | Wed | Omar |
| 7 | Puzzle | Toys | 4 | Wed | Grace |
| 8 | Book cooking | Books | 3 | Thu | Sophie |
| 9 | Radio | Electrical | 15 | Thu | Omar |
| 10 | T-shirt XL | Clothing | 4 | Fri | Sophie |
| 11 | Dress black | Clothing | 18 | Fri | Grace |
| 12 | What? Game | Toys | 5 | Sat | Omar |
| 13 | Vase | Household | 7 | Sat | Grace |
| 14 | T-shirt M | Clothing | 3 | Sat | Sophie |
| 15 | Bookend | Household | 9 | Sat | Omar |
| 16 | Kids' bike | Toys | 35 | Sat | Grace |
=AVERAGEIF(B2:B16,"Clothing",C2:C16)The formula returns £7.67. AVERAGEIF finds Clothing in column B, gets six rows and divides their £46 by 6. With "Household" you get £8: the lamp, the vase and the bookend come to £24, divided by 3. So there's Yasmina's answer: household goods are just a little dearer.
Try it yourself with a category that has a story to tell. The exercise runs on Second Chance's real sheet, and you type the formula as you would in Excel.
Try it: what do toys cost on average?
What does a toy cost on average? Work it out in I2 with AVERAGEIF.
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Item | Category | Price | Day | Volunteer | Limit | ||||
| 2 | Dress green | Clothing | £12.00 | Mon | Sophie | £10.00 | ||||
| 3 | Book fiction | Books | £2.00 | Mon | Omar | |||||
| 4 | Lamp | Household | £8.00 | Tue | Sophie | |||||
| 5 | T-shirt S | Clothing | £3.00 | Tue | Grace | |||||
| 6 | Dressing gown | Clothing | £6.00 | Wed | Omar | |||||
| 7 | Puzzle | Toys | £4.00 | Wed | Grace | |||||
| 8 | Book cooking | Books | £3.00 | Thu | Sophie | |||||
| 9 | Radio | Electrical | £15.00 | Thu | Omar | |||||
| 10 | T-shirt XL | Clothing | £4.00 | Fri | Sophie | |||||
| 11 | Dress black | Clothing | £18.00 | Fri | Grace | |||||
| 12 | What? Game | Toys | £5.00 | Sat | Omar | |||||
| 13 | Vase | Household | £7.00 | Sat | Grace | |||||
| 14 | T-shirt M | Clothing | £3.00 | Sat | Sophie | |||||
| 15 | Bookend | Household | £9.00 | Sat | Omar | |||||
| 16 | Kids' bike | Toys | £35.00 | Sat | Grace | |||||
| 17 |
Your formula ran in your own browser, on a real calculation engine. Then we run it again on a hidden version of the sheet, with other prices, so copying the answer won't help.
How do you use criteria in AVERAGEIF?
Just as in SUMIF: text and operators go in quotation marks, you join a cell on with &, and wildcards work too (Microsoft). If you test the same column you're averaging, you can drop the third argument.
| Question | Formula | Result |
|---|---|---|
| Grace's average item | =AVERAGEIF(E2:E16,"Grace",C2:C16) | £13.40 |
| Everything under £10 | =AVERAGEIF(C2:C16,"<10") | £4.91 |
| Everything above the limit in G2 | =AVERAGEIF(C2:C16,">"&G2) | £20 |
| Anything starting with Dress | =AVERAGEIF(A2:A16,"Dress*",C2:C16) | £12 |
The sheet as a whole comes to £8.93, with =AVERAGE(C2:C16). Grace is well above that, but it says little about her: she happened to sell the kids' bike. A comparison like that is only fair once you know what's behind the number.
How do you calculate an average with multiple conditions?
With AVERAGEIFS: the numbers first, then the pairs, just like SUMIFS. Only the rows where every condition holds count. =AVERAGEIFS(C2:C16,B2:B16,"Clothing",E2:E16,"Sophie") returns £6.33: Dress green, T-shirt XL and T-shirt M together make £19, divided by 3.
Between two values, you use the same column twice. =AVERAGEIFS(C2:C16,C2:C16,">=5",C2:C16,"<=10") returns £7 for the five items from £5 to £10. That's also how you leave outliers out: =AVERAGEIFS(C2:C16,B2:B16,"Toys",C2:C16,"<"&G2) returns £4.50 for the toys under the limit. Try it yourself.
Try it: Saturday without the toys
What did an item cost on average on Saturday, leaving out the toys? Work it out in I2 with AVERAGEIFS.
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Item | Category | Price | Day | Volunteer | Limit | ||||
| 2 | Dress green | Clothing | £12.00 | Mon | Sophie | £10.00 | ||||
| 3 | Book fiction | Books | £2.00 | Mon | Omar | |||||
| 4 | Lamp | Household | £8.00 | Tue | Sophie | |||||
| 5 | T-shirt S | Clothing | £3.00 | Tue | Grace | |||||
| 6 | Dressing gown | Clothing | £6.00 | Wed | Omar | |||||
| 7 | Puzzle | Toys | £4.00 | Wed | Grace | |||||
| 8 | Book cooking | Books | £3.00 | Thu | Sophie | |||||
| 9 | Radio | Electrical | £15.00 | Thu | Omar | |||||
| 10 | T-shirt XL | Clothing | £4.00 | Fri | Sophie | |||||
| 11 | Dress black | Clothing | £18.00 | Fri | Grace | |||||
| 12 | What? Game | Toys | £5.00 | Sat | Omar | |||||
| 13 | Vase | Household | £7.00 | Sat | Grace | |||||
| 14 | T-shirt M | Clothing | £3.00 | Sat | Sophie | |||||
| 15 | Bookend | Household | £9.00 | Sat | Omar | |||||
| 16 | Kids' bike | Toys | £35.00 | Sat | Grace | |||||
| 17 |
How do you leave zeros out of an average?
Use ">0" as the criteria on the numbers themselves. At The Splash swimming pool in Tamworth, manager Dave recorded the visits of ten members. Laura's cell is empty, and Sara has never been. =AVERAGE(D2:D11) returns 9.78 visits, because Sara's 0 counts and Laura's empty cell doesn't. =AVERAGEIF(D2:D11,">0") returns 11 visits, the average of those who actually came.
Which number is right depends on your question. How often does a member come on average? Then Sara counts. How often does someone who comes, come? Then she doesn't. The function skips an empty cell anyway (Microsoft), so watch the difference between "not filled in" and "really zero". There's more on that in the article on AVERAGE.
Why isn't my AVERAGEIF working?
An average can go wrong in three ways: it gives an error, it works on the wrong rows, or it's mathematically right but misleading. That last one is the most dangerous, because Excel won't complain.
The formula returns #DIV/0!
No row meets the condition, or there are no numbers in the cells you're averaging (Microsoft). No furniture was sold, so =AVERAGEIF(B2:B16,"Furniture",C2:C16) returns #DIV/0!. That's an honest answer: there is no average. If you'd like to show something readable, write:
=IFERROR(AVERAGEIF(B2:B16,"Furniture",C2:C16),"No sales")Don't replace it with a 0: an average of £0 isn't the same as no average. Microsoft warns that IFERROR suppresses every error (Microsoft). You can read when that does harm in IFERROR and IFNA.
The ranges are shifted
AVERAGEIF doesn't check the size of the last range: Excel starts at its first cell and takes a block in the same shape as the first range (Microsoft). So =AVERAGEIF(B2:B16,"Clothing",C3:C16) returns £7.33 instead of £7.67, with no message at all. AVERAGEIFS is stricter: each criteria range must be the same size and shape as the average range (Microsoft).
An average of averages is wrong
Take the average of the five category averages and you get £9.57, while the true average is £8.93. Every category then counts equally, whether it has one item like Electrical or six like Clothing.
Never average a set of averages. Go back to the raw rows, or weight each average by its count.
Which functions are like AVERAGEIF?
The family holds no secrets by now: the same criteria, the same pairs, a different calculation. On Second Chance's sheet, for Sophie's clothing:
| Function | What it does | Result |
|---|---|---|
| COUNTIFS | Counts the rows | 3 items |
| SUMIFS | Adds up the prices | £19 |
| AVERAGEIFS | Takes the average, which is sum divided by count | £6.33 |
To count, read COUNTIFS with examples. For amounts, there's SUMIFS with examples. Every function is on the Excel cheat sheet with its Dutch name. If you want to do all of this yourself, follow module 4 of the Excel course, and start with the free modules if you're new to Excel.
Frequently asked questions
What's the difference between AVERAGEIF and AVERAGEIFS?
AVERAGEIF has one condition, AVERAGEIFS one or more, up to 127. The order differs too. AVERAGEIF has the range of numbers last, and you can even leave it out. AVERAGEIFS has it first, just like SUMIFS, and all its ranges must be the same size and shape.
Why does AVERAGEIF return
Because no row meets the condition, or because the cells you're averaging are empty or hold text. An average is a sum divided by a count, and without numbers you divide by zero. Catch it with IFERROR, or first test with COUNTIF whether there are any matching rows.
How do you calculate an average without zeros?
Use the criteria ">0" on the numbers themselves: =AVERAGEIF(D2:D11,">0"). You can drop the third argument, because you test and average in the same column. The function skips empty cells anyway, and zeros only if you ask it to. Do think about whether a 0 really shouldn't count.
Can AVERAGEIF use text and wildcards?
Yes. Text goes in quotation marks and capitals don't matter. Use * for a run of characters and ? for exactly one, as in "Dress*" for anything starting with Dress. To find a real question mark or asterisk, put a tilde in front: ~? or ~*. The same rules apply to AVERAGEIFS.
How do you round the result of AVERAGEIF?
Wrap ROUND around it: =ROUND(AVERAGEIF(B2:B16,"Clothing",C2:C16),2) returns 7.67. If you only want to show fewer decimals, use a number format on the cell instead: the full value stays behind it, so later calculations don't drift. Round when the rounded number itself needs to carry on.
Practise this in the course
Every lesson explains first and then lets you practise yourself, with a real spreadsheet in your browser.
- AVERAGEIFCounting and adding with conditions · An average with a condition
- SUMIFSCounting and adding with conditions · Several conditions
- AVERAGEFunctions and references · The average
Sources
- Microsoft Support, AVERAGEIF function
- Microsoft Support, AVERAGEIFS function
- Microsoft Support, How to correct a
Christophe, founder of Lurndo
Christophe builds Lurndo from Belgium, with short, playful exercises for SQL, Excel, HTML & CSS and touch typing that show straight away what your answer does. On this blog, Christophe answers the questions people run into while learning, with sources you can check yourself.
Read next
Excel COUNTIFS examples: counting with multiple criteria, including between two valuesHow many items over £5 did Grace sell? On a charity shop's real sheet you'll see how COUNTIFS counts row by row, and you can write one yourself right away.Excel · · 7 min read
IFERROR and IFNA in Excel: catching errors without hiding the real onesA #DIV/0! or #N/A looks messy, but it's information too. On the sheets of a swimming pool and a bike courier, you'll see how to catch them neatly, and when to leave them alone.Excel · · 6 min read