AVERAGEIF scans the range argument and compares each cell to the criteria. For every matching row it records the corresponding value in average_range, sums them all, then divides by the count of matching rows. The average excludes non-matching rows entirely — it is not an average of zeros, it is an average of only the values that qualified. Blank cells and text in the average_range are ignored, so missing values do not deflate the average. If no rows match the criteria, AVERAGEIF returns #DIV/0! because it tries to divide by zero — wrap it in IFERROR to handle this cleanly in reports. The criteria argument follows exactly the same rules as
SUMIF and
COUNTIF: text must be in quotes, numbers do not need quotes, comparison operators go inside the quotes, and cell references are joined to operators using the & concatenation operator. When average_range is omitted, AVERAGEIF averages the values in range that match the criteria directly.