Excel Lessons

AVERAGEIF and AVERAGEIFS in Excel, with examples

AVERAGEIF averages only the rows that meet a condition; AVERAGEIFS allows several. Examples, the argument order that differs, and #DIV/0! with no match.

Published . 6 min read.

By Ali, Founder, Excel Lessons

AVERAGEIF gives the average of only the rows that meet one condition. AVERAGEIFS does the same with one or more conditions. Both work in every current version of Excel.

Here is a help desk's ticket log. Each row is a ticket, with the team that closed it and the hours it took. Ticket T-106 is still open, so its Hours cell is empty. Type the table in A1 to D10.

Row A B C D
1 TicketTeamPriorityHours
2 T-101BillingHigh3
3 T-102NetworkLow10
4 T-103BillingLow6
5 T-104AccountsHigh2
6 T-105NetworkHigh5
7 T-106BillingHigh
8 T-107AccountsLow7
9 T-108NetworkHigh6
10 T-109BillingLow9

AVERAGEIF: one condition

The shape is =AVERAGEIF(range, condition, average_range). The range is where Excel looks for the condition. The average range holds the numbers to average.

Average hours for Billing: =AVERAGEIF(B2:B10,"Billing",D2:D10) gives 6.

Billing has 4 tickets, but one of them has no hours. AVERAGEIF skips the empty cell. It adds 3, 6 and 9, and divides by 3.

The condition can be a comparison. When the numbers you test are the numbers you average, leave out the third part.

Average of the tickets that took 6 hours or more: =AVERAGEIF(D2:D10,">=6") gives 7.6.

The 5 tickets are 10, 6, 7, 6 and 9 hours. The comparison goes in quote marks.

The condition can also be a cell. Type Network in F2. Then =AVERAGEIF(B2:B10,F2,D2:D10) gives 7. Change F2 to Accounts and it gives 4.5. A cell reference needs no quote marks.

AVERAGEIFS: several conditions

The shape is =AVERAGEIFS(average_range, range1, condition1, range2, condition2). You can add more pairs. A row is averaged only when every pair is true.

Average hours for Network tickets that are High: =AVERAGEIFS(D2:D10,B2:B10,"Network",C2:C10,"High") gives 5.5.

That is T-105 and T-108, which took 5 and 6 hours.

The argument order is not the same

This is the mistake everybody makes once. AVERAGEIF puts the numbers last. AVERAGEIFS puts them first.

  • =AVERAGEIF(B2:B10,"Billing",D2:D10): where to look, what to find, what to average.
  • =AVERAGEIFS(D2:D10,B2:B10,"Billing"): what to average, then where to look and what to find.

Both give 6. AVERAGEIFS uses the same order as SUMIFS, so if you know SUMIFS, you know this. My advice is to always write AVERAGEIFS, even for one condition. Then there is only one order to remember.

If you leave out the numbers by mistake, AVERAGEIF averages the condition column. =AVERAGEIF(B2:B10,"Billing") tries to average the word Billing. It finds no numbers and gives #DIV/0!.

Count the rows behind every average

An average does not tell you how many rows it used. Put a COUNTIFS next to it, with the same conditions.

=AVERAGEIFS(D2:D10,B2:B10,"Accounts",C2:C10,"Low") gives 7.

=COUNTIFS(B2:B10,"Accounts",C2:C10,"Low") gives 1.

So the "average" is one ticket. A manager who reads 7 hours should know that.

COUNTIFS also shows the empty cells. =COUNTIFS(B2:B10,"Billing") gives 4. =COUNTIFS(B2:B10,"Billing",D2:D10,"<>") gives 3. The condition "<>" means "not empty". The difference is the open ticket.

Empty is skipped, 0 is counted

Someone types 0 in D7 to mean "no hours yet". Now =AVERAGEIF(B2:B10,"Billing",D2:D10) gives 4.5, not 6. The 0 is a real number to Excel, so Billing looks faster than it is.

Leave a cell empty when there is no value yet. If your export puts 0 in every open row, add a condition to skip it: =AVERAGEIFS(D2:D10,B2:B10,"Billing",D2:D10,">0").

No match gives #DIV/0!

SUMIFS and COUNTIFS give 0 when nothing matches. The average of nothing is not 0, so AVERAGEIF and AVERAGEIFS give #DIV/0!.

=AVERAGEIFS(D2:D10,B2:B10,"Security") gives #DIV/0!. There is no Security team in the log.

=IFERROR(AVERAGEIFS(D2:D10,B2:B10,"Security"),"No tickets") gives No tickets.

IFERROR hides every error, not only this one. A typing mistake in the formula would also show No tickets. A safer way tests the count first:

=IF(COUNTIFS(B2:B10,"Security")=0,"No tickets",AVERAGEIFS(D2:D10,B2:B10,"Security")) also gives No tickets.

It is longer. But any other error still shows, so you can find it. The #DIV/0! article explains why IFERROR is the last choice.

Do not average the averages

The 3 team averages are 6 for Billing, 7 for Network and 4.5 for Accounts. Their average is about 5.83. But the average of all 8 closed tickets is =AVERAGE(D2:D10), which gives 6.

The two numbers differ because the teams closed different numbers of tickets. Accounts closed 2, and it counts as much as Billing's 3. For an overall figure, always average the rows, not the results.

Questions people ask

Is AVERAGEIF case-sensitive?

No. =AVERAGEIF(B2:B10,"billing",D2:D10) also gives 6. Spaces do matter. "Billing " with a space at the end does not match.

How do I average everything except one team?

Use "<>Billing" as the condition. =AVERAGEIF(B2:B10,"<>Billing",D2:D10) gives 6 for the other 5 tickets.

Can the condition use a wildcard?

Yes, for text. "Net*" matches any team that starts with Net. The rules are the same as in SUMIF and COUNTIF. The SUMIF and SUMIFS practice article has more conditions to try.

The AVERAGEIF, AVERAGEIFS and COUNTIFS lessons below use other sheets. Each lesson is a real sheet you type into, and each answer is checked when you press Enter.

Related articles