Category: FUNCTION | Updated: 2026-11-22

How to Use the AVERAGEIF Function in Google Sheets | Calculate the Average of Numbers Matching a Condition

How to Use the AVERAGEIF Function

The AVERAGEIF function is a statistical function that finds cells matching a single specified criterion and calculates the arithmetic mean (average) of the corresponding numeric values.

Syntax

=AVERAGEIF(criteria_range, criterion, [average_range])
  • criteria_range: The cell range to test against the criterion, such as B2:B20 (required).
  • criterion: The condition used to filter which items to average (text, number, comparison operator, etc.) (required).
  • average_range: The cell range containing the actual numbers to average, such as C2:C20. If omitted, criteria_range itself is averaged (optional).

Table Example

Here is an example of calculating the average review rating for "Laptop" from the product review table below.

Row Column A (Review ID) Column B (Category) Column C (Rating)
1 Review ID Category Rating
2 R001 Laptop 4.5
3 R002 Mouse 4.0
4 R003 Laptop 5.0
5 R004 Keyboard 3.5
6 R005 Laptop 4.0
  • Formula: =AVERAGEIF(B2:B6, "Laptop", C2:C6)
  • Result: 4.5 ((4.5 + 5.0 + 4.0) ÷ 3)

Common Errors and Notes

  • #DIV/0! error when 0 items match: If no cells match the criterion, division by zero occurs and #DIV/0! is returned. Wrapping it in IFERROR is standard practice.
  • Difference between "0" and "blank": A 0 in average_range lowers the average, whereas a blank cell is excluded from the calculation. If you want to exclude zeros from the average, use AVERAGEIFS and add the criterion ">0".
  • Argument order difference from AVERAGEIFS: AVERAGEIF places average_range at the end, whereas AVERAGEIFS (for multiple criteria) places average_range first.

Frequently Asked Questions

Q. What happens if no data matches the criterion in AVERAGEIF?

A. Because the denominator becomes 0, a "#DIV/0!" error is displayed. To hide the error, wrap it in IFERROR, such as =IFERROR(AVERAGEIF(...), 0) or =IFERROR(AVERAGEIF(...), "-").

Q. Does AVERAGEIF include cells containing "0" in the denominator?

A. Yes, numeric "0" is counted as a data point and included in the denominator. On the other hand, blank cells and cells containing text are automatically excluded from the average.