Excel function

AVERAGEIFfunction

Averages only the values in rows that meet a condition.

All versions
=AVERAGEIF(B2:B9, "Apple", C2:C9)
Range to drag
A
B
C
D
1
2
3
4
5
6
7
8
9

Drag the corner dots to change range, average_range. Click a cell in the criteria range to use its value as the criteria. Change the criteria to "Melon". No cell matches, so you get #DIV/0!. Try breaking it on purpose to see the errors.

Result

25

range
B2:B9Drag a corner dot up/down to resize, sideways to change the column

The column checked against the condition.

criteria

The condition that picks the rows to average.

average_range
C2:C9

The column to average. If omitted, range itself is averaged.

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

  1. 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.

  2. 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.

  3. 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

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), "").