AVERAGEIF (average if condition is true)

<< Click to Display Table of Contents >>

AVERAGEIF (average if condition is true)

Syntax:

AVERAGEIF(Range, Criterion [, AverageRange])

Description:

Returns the arithmetic mean of those values in a cell range that fulfill the specified criterion.

Range is the cell range to be evaluated.

Criterion is the condition that the values in Range have to fulfill to be included:

Use numbers or text (like "42" or "bolts") to obtain the average of all cells that contain that value.

Use conditions (like ">10" or "<=5") to obtain the average of all cells that match the specified condition.

Note: Criteria always have to be surrounded by double quotation marks (").

AverageRange (optional) lets you specify the cell range containing the values to be used for calculating the average. If omitted, the values in Range will be used.

Compatibility notes:

This function is not supported by the .xls file format (used in Microsoft Excel 2003 and earlier). If you save a document in this format, all calculations using this function will be replaced by their last result as a fixed value.

Accordingly, if you use this function, you should not save your document in the "Microsoft Excel 97-2003 (.xls)" file format, but choose one of the following formats instead:

"PlanMaker document (.pmdx or .pmd)"

or: "Microsoft Excel 2007-2021 (.xlsx)"

Example:

The cells A1:A5 contain the values 1, 2, 3, 2, 1. The following applies:

AVERAGEIF(A1:A5, "2") returns 2

AVERAGEIF(A1:A5, ">=2") returns (2+3+2)/3, which gives 2.33333

See also:

AVERAGE, AVERAGEIFS, SUMIF, SUMIFS, COUNTIF, COUNTIFS