AVERAGEIF() function returns the average of selected cells that meet the specified condition.
Syntax
=AVERAGEIF(range,criteria,average_range)
Where:
- range: represents one or more cells to calculate the average, which can be numbers, named ranges, arrays, or references containing numbers.
- criteria: is the condition in the form of a number, expression, cell reference, or text that specifies which cells to average.
- average_range: collection of cells to actually calculate the average, if average_range is omitted, then range will be used to calculate the average.
Note
- Empty cells in average_range are ignored.
- Logical values (TRUE or FALSE) in range are also ignored.
- If range is empty or contains text, AVERAGEIF() function will return an error.
- If criteria contains an empty cell, it will be treated as 0.
- If no cells in the range meet the criteria, AVERAGEIF() function reports an error.
- You can utilize wildcard characters such as question mark (?) to substitute for any single character, asterisk (*) to replace any string in the criteria. When the criteria contain ? or *, type ~ before them.
- Average_range and range do not necessarily have to be of the same size. The actual cells averaged will use the top-left cell of average_range as the starting point, including additional cells corresponding to the size of the range. For a clearer understanding, refer to the example below:
Example
Example 1:
Example 2:
With these two examples, you will gain a clearer understanding of how to use the AVERAGEIF() function in Excel. Wishing you success!