AVERAGEIF Function
AVERAGEIF is a combination of the AVERAGE function and a conditional component. AVERAGEIF returns the average (or arithmetic mean) of all the cells in a range that meet a specified condition.
Syntax
AVERAGEIF(range, criteria, [average_range])
Arguments
Argument
Description
Range
Required. A reference to one or more cells to average. This argument can include numbers, cell references, or named ranges.
Criteria
Required. This is a logical test that determines which cells are included in the average .
Average_range
Optional. The actual set of cells to average if not the cells in the range argument. If this argument is omitted, range is used.
Notes:
Example
In the following example, we use the AVERAGEIF function to calculate the average exam scores for students per subject. We want to group the data by Subject (for example, Biology, Chemistry, Maths etc.) and average each group by Score .
The range we will be using to select the data - B2:B16, is different from the range we want to actually average - C2:C16.
Formula explanation:
=AVERAGEIF($B$2:$B$16,E2,$C$2:$C$16)
We enter the formula in cell F2 to return the Maths average. Then the Fill Handle of the cell was used to copy the formula to cells F3:F5 which displays the average for the other subjects.