What is the AVERAGEIF function?
=AVERAGEIF(range, criteria, [average_range])AVERAGEIF averages only the values in rows that meet a condition, such as the average quantity of apple orders.
It adds the matching values while counting them, then divides the total by the count. The steps show the total and the count growing together.
Arguments
- range
- The cells checked against the condition.
- criteria
- The condition that picks the rows. Write "Apple", ">=20" or "<>Seoul"; wildcards ? and * work.
- average_range
- The cells to average. If omitted, range is averaged. Blank cells here are left out.
AVERAGEIF examples
Example 1. Average quantity of apple orders
=AVERAGEIF(B2:B9, "Apple", C2:C9)Apple quantities 30, 20 and 25 add up to 75; with 3 of them the average is 25. This is how the sheet first opens.
Example 2. Average sales for Busan
=AVERAGEIF(A2:A9, "Busan", D2:D9)Busan sales 28800, 67500 and 37500 add up to 133800; divided by 3 that is 44600.
Example 3. Average of quantities of 20 or more
=AVERAGEIF(C2:C9, ">=20")With average_range omitted, range itself is averaged: 30, 20, 40 and 25 average 28.75.
Common mistakes
No matching values
If no row matches, it divides by 0 and returns #DIV/0!. Try "Melon" above. If that can happen, wrap it: =IFERROR(AVERAGEIF(…), 0).
Expecting blanks to count as 0
Blank cells in average_range are left out, not counted as 0. Type 0 if it should count.
Needing two conditions
AVERAGEIF takes one condition. Use AVERAGEIFS for more; its argument order is different, with average_range first.
FAQ
- How is it different from AVERAGE?
- AVERAGE averages the whole range; AVERAGEIF averages only the matching values.
- average_range a different size?
- No error. It starts at the top-left cell of average_range and uses a block the size of range. Keep both the same size to avoid confusion.
- Show a blank instead of #DIV/0!?
- Wrap it in IFERROR: =IFERROR(AVERAGEIF(B2:B9, F2, C2:C9), "").