Practice free

AVERAGEIF function

AVERAGEIF averages only the rows that meet one condition, for example the average sales for one region. Use AVERAGEIFS when you need more than one condition.

Example

Read it as a sentence: look down M2:M7 (the Region column) for North and average the matching sales from O2:O7, which gives 150.

Practice this in the app

Syntax

AVERAGEIF(range, criteria, [average_range])

Arguments in [square brackets] are optional.

range (required)
Cells tested against the criteria.
criteria (required)
Condition such as 5, ">3" or "apple*".
average_range (optional)
Cells to average; if omitted, range itself is averaged.

Returns: The mean of the cells that meet the condition.

What Excel actually returns

Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.

FormulaExcel showsCase
=AVERAGEIF(Data!M2:M7,"North",Data!O2:O7) 150 Text criteria, separate average range
=AVERAGEIF(Data!O2:O7,">80") 150 Criteria on own range
=AVERAGEIF(Data!M2:M7,"South",Data!O2:O3) 112.5 average_range smaller (resized from top-left)
=AVERAGEIF(Data!M2:M7,{"North";"South"},Data!O2:O7) 150 Array criteria spill
=AVERAGEIF(Data!C1:C5,">0") 3 Range with #N/A in averaged cells
=AVERAGEIF(Data!M2:M7,"West",Data!O2:O7) #DIV/0! No match
=AVERAGEIF(Data!M2:M7,"North",Data!E1:E6) #DIV/0! Average range all text

The Data sheet these formulas read

A cell that starts with = holds that formula.

Watch out for

  • Needs real cell ranges; array constants return #VALUE!.
  • Returns #DIV/0! when no cell matches.
  • average_range should be the same size as range.
  • Excel refuses the formula outright if you type an array constant such as {1,2,3} where a range is expected; point it at cells instead (measured in Excel 16.0.20527).

Where it works

Excel
AVERAGEIF is in every version of Excel from 2007 on.
Google Sheets
Same name, same behaviour for everyday use.

Part of Statistical functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .