What AVERAGEIF does

AVERAGEIF averages the numbers on the rows that meet one condition. =AVERAGEIF(B2:B7,"Online",C2:C7) looks down B2:B7 for Online and averages the order values beside those rows in C2:C7. It’s how you get the average order value for one sales channel, or an average that leaves out the zeros.

Picture SUMIF and COUNTIF working together: AVERAGEIF adds the numbers on the matching rows and divides by how many rows matched. Rows that don’t match are left out of both, so they can’t pull the average up or down.

Conditions are written as in SUMIF: text such as "Online", a comparison such as ">0", or a cell. For several conditions at once, use AVERAGEIFS.

Syntax

=AVERAGEIF(range, criteria, [average_range])
Arguments in square brackets are optional; the rest are required.
rangeRequired
The cells to test, such as the channel column B2:B7. Without average_range, these are also the numbers that get averaged.
criteriaRequired
The condition: "Online", ">0", a number or a cell. Join an operator to a cell with &: ">="&F1. In text, * stands for any characters and ? for one.
average_rangeOptional
Optional. The numbers to average, such as the order values in C2:C7, on the same rows as range. Leave it out to average the tested cells themselves.

Example: average order value for one channel

An online shop logs every order with its sales channel in column B and its value in column C.

Rows 2, 4 and 6 are Online orders: (90 + 48 + 117) ÷ 3 = 85. In C8, =AVERAGEIF(B2:B7,"Online",C2:C7) returns 85.00.

Read it as: average C2:C7 on the rows where B2:B7 says Online. The average of all six orders is 111.50, so the online orders come in well below the shop’s average.

Example: average without the zeros

A payroll clerk averages the overtime hours of the people who did any. Ben and Dan did no overtime this month, and their 0s would drag the average down.

(6 + 4.5 + 9) ÷ 3 = 6.5. AVERAGE(B2:B6) gives 3.9, because it counts the two zeros. In B7, =AVERAGEIF(B2:B6,">0") returns 6.5.

With no third argument, AVERAGEIF tests and averages the same cells. An empty cell is skipped anyway, so this matters only when the sheet records a 0.

When AVERAGEIF returns #DIV/0!

When no row meets the condition, there’s nothing to divide by and AVERAGEIF shows #DIV/0!. On the orders above, =AVERAGEIF(B2:B7,"Email",C2:C7) gives #DIV/0! because no order came by email.

If an empty result is normal, as in a report where some channels have no orders yet, wrap the formula in IFERROR: =IFERROR(AVERAGEIF(B2:B7,"Email",C2:C7),"No orders") shows No orders instead. If you expected matches, look for a typo or a trailing space in the condition or the data.

Common mistakes

  • =AVERAGEIF(C2:C7,"Online",B2:B7) has the ranges swapped and returns #DIV/0!, because no order value says Online. AVERAGEIF takes the range to test first and the numbers last. AVERAGEIFS takes the numbers first.
  • =AVERAGEIF(C2:C7,">F1") compares with the text F1, matches nothing and returns #DIV/0!. Join the operator to the cell with &: =AVERAGEIF(C2:C7,">"&F1).
  • A condition that points at an empty cell counts as 0, so =AVERAGEIF(B2:B7,F2,C2:C7) with nothing in F2 returns #DIV/0! instead of averaging everything.
  • =SUMIF(B2:B7,"Online",C2:C7)/6 divides by every order instead of the three that matched. Divide by a COUNTIF of the same condition, or use AVERAGEIF.

Frequently asked questions

How do I average only the numbers greater than 0?

Use ">0" as the condition and leave out the third argument: =AVERAGEIF(B2:B6,">0") averages the cells in B2:B6 that hold more than 0. "<>0" also keeps negative numbers.

How do I use AVERAGEIF with multiple criteria?

AVERAGEIF takes one condition. For two or more, use AVERAGEIFS, which takes the numbers first and then pairs of range and condition: =AVERAGEIFS(C2:C7,B2:B7,"Online",C2:C7,">50").

Why does AVERAGEIF return #DIV/0!?

No row met the condition, so there’s nothing to divide by. Check the condition for typos and the data for trailing spaces, and check that the range to test comes first. When no match is normal, IFERROR can show a message instead.

Does AVERAGEIF ignore blank cells?

Yes. Empty cells in the range being averaged are skipped. A 0 counts like any other number, so test for ">0" to leave zeros out.

Can AVERAGEIF use wildcards?

Yes, in text conditions. =AVERAGEIF(A2:A50,"*desk*",C2:C50) averages the rows whose product name contains desk. An asterisk stands for any characters and a question mark for one.