Get the average of numbers that meet criteria.
=AVERAGEIF(range, criteria, [average_range])
| Parameter | Description |
|---|---|
range |
One or more cells, including numbers or names, arrays, or references. |
criteria |
A number, expression, cell reference, or text. |
average_range |
[optional] The cells to average. When omitted, range is used. |
The generic syntax for AVERAGEIF looks like this:
=AVERAGEIF(range,criteria,[average_range])
In the example shown, the formulas in H5:H8 are as follows:
=AVERAGEIF(C5:C15,">0") // price greater than $0
=AVERAGEIF(C5:C15,">200000") // price greater than $200k
=AVERAGEIF(D5:D15,">=2",C5:C15) // 2+ bedrooms
=AVERAGEIF(D5:D15,">=3",C5:C15) // 3+ bedrooms
In general, text values are enclosed in double quotes (""), and numbers are not. However, when a logical operator is included with a number, the numbe
=AVERAGEIF(D5:D15,2,C5:C15) // 2 bedrooms
=AVERAGEIF(D5:D15,">=2",C5:C15) // 2+ bedrooms
Double quotes are also used for text values. For example, to average values in B1:B10 when values in A1:A10 equal "red", you can use a formula like th
=AVERAGEIF(A1:A10,"red",B1:B10) // average "red" only
A value from another cell can be included in criteria using concatenation. In the example below, AVERAGEIF will return the average of numbers in A1:A1
=AVERAGEIF(A1:A10,"<"&B1) // average values less than B1
The wildcard characters question mark (?), asterisk(), or tilde (~) can be used in criteria. A question mark (?) matches any one character, and an ast
=AVERAGEIF(A1:A10,"*red*",B1:B10) // contains "red"