Function · Statistical

Excel AVERAGEIF function

The Excel AVERAGEIF function averages numbers whose neighbor matches one test. The two Electric bills, $143.60 and $118.45, average $131.025.

Excel 2007 and later. Also in Excel for the web and Google Sheets.

Syntax =AVERAGEIF(range, criteria, [average_range])

AVERAGEIF
=AVERAGEIF(A2:A5,"Electric",B2:B5)

Arguments

NameRequiredWhat to pass
rangeRequiredThe cells to test.
criteriaRequiredThe test. A word, a number, or an expression such as ">100". Text matches ignore case. * and ? are wildcards.
average_rangeOptionalThe numbers to average. If you omit it, the tested range is averaged. It must be the same shape as range.

Examples

Average of the Electric rows only

=AVERAGEIF(A2:A5,"Electric",B2:B5)

Result $131.025

=AVERAGEIF(A2:A5,"Electric",B2:B5)B6
Utilities
AB
1CategoryAmount
2Electric143.60
3Gas96.20
4Water48.00
5Electric118.45
6Electric average131.025
A picture of the sheet, not a live calculator. Matching is not case-sensitive. electric would match Electric.

AVERAGEIF averages one group. Electric is $143.60 and $118.45, so the average is $131.025. Gas and Water stay out of the total and out of the count. That is the difference from AVERAGE of the whole column, which would mix every category and land on a number that describes none of them.

The test is not case-sensitive, and a criterion of ">100" works when the range itself holds the numbers. Leave average_range off in that case. When the word is in column A and the dollars are in column B, pass both ranges, and keep them the same height. One test is the limit. A city and a category together need AVERAGEIFS.