Going Stellar

Home/Google Sheets reference

Google Sheets function · Statistical

AVERAGEIFS in Google Sheets: syntax and examples

AVERAGEIFS calculates the average of a range, but only over the rows where every condition is true. Each condition is a pair of a range and a criterion, and you can add as many pairs as you need.

Syntax

AVERAGEIFS(average_range, criteria_range1, criterion1, [criteria_range2, criterion2, ...])

Arguments

ArgumentTypeRequiredWhat it does
average_rangerangeyesThe cells that are averaged when every condition is met.
criteria_range1rangeyesThe first range tested. It must have the same size as average_range.
criterion1anyyesThe condition for criteria_range1: a value, a text, or a comparison such as ">5" in quotes.
criteria_range2, criterion2, ...anynoMore pairs of range and condition. A row counts only if it passes all pairs.

Examples

The examples use this table, starting in A1:

RegionChannelOrdersValue
NorthWeb10120.5
NorthShop480
SouthWeb895
SouthShop660
EastWeb12150
=AVERAGEIFS(D2:D6, A2:A6, "North")

Result: 100.25

Average value of the rows where Region is North.

Run in a Google Sheet (English US locale) on .

=AVERAGEIFS(D2:D6, A2:A6, "North", B2:B6, "Web")

Result: 120.5

Two conditions at once: both must be true, so only one row is left.

Run in a Google Sheet (English US locale) on .

=AVERAGEIFS(D2:D6, C2:C6, ">7.5")

Result: 121.8333333

A numeric comparison inside the criterion. In the RO file the decimal in the string is written with a comma.

Run in a Google Sheet (English US locale) on .

=AVERAGEIFS(D2:D6, A2:A6, "<>South")

Result: 116.8333333

<> excludes a value: every region except South.

Run in a Google Sheet (English US locale) on .

=AVERAGEIFS(D2:D6, B2:B6, "S*")

Result: 70

The wildcard * matches any ending, so this takes the Shop rows.

Run in a Google Sheet (English US locale) on .

Common errors

  • When no row passes all the conditions, the result is #DIV/0!, because there is nothing to average. Wrap the formula in IFERROR to show a default.
  • The average range and every criteria range must have the same size. Passing D2:D5 with A2:A6 returns #VALUE!.
  • Conditions are joined with AND: a row must pass every pair. There is no OR inside AVERAGEIFS.

Compared with Excel

Same syntax as Excel AVERAGEIFS.

Sources

  1. AVERAGEIFS (Docs Editors Help)

Markdown version · All functions