ShareYourGroupShareYourGroupExcel Formulas

Statistical functions

AVERAGEIF and AVERAGEIFS functions in Excel

AVERAGEIF averages the cells that meet one condition; AVERAGEIFS allows several conditions.

AVERAGEIF is to AVERAGE what SUMIF is to SUM. It answers "what is the average for this group?": the average mark of one class, the average bill for one city, the average delivery time for one courier.

Syntax

=AVERAGEIF(range, criteria, [average_range])
=AVERAGEIFS(average_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)
ArgumentWhat it is
rangeThe cells to test.
criteriaThe condition, written as in SUMIF: "8A", ">50", or a cell reference.
average_rangeThe cells to average. In AVERAGEIF it comes last and may be left out. In AVERAGEIFS it comes first.

Examples

Each result below is what Excel itself showed for the formula on the sample sheet.

Sample sheet: Marks of eight students in three subjects. One Science mark is missing (cell D6 is empty).
ABCDE
1NameClassMathsScienceEnglish
2Asha8A788591
3Ravi8B455260
4Meena8A928879
5Kabir8B334138
6Tara8A6772
7Joy8B889084
8Neha8A546158
9Imran8B787369

How it works

AVERAGEIF tests each cell in the first range. For the rows that pass, it averages the matching cells of the third range. It is the same as dividing SUMIF by COUNTIF, in one function.

AVERAGEIFS takes several conditions and averages the rows that pass all of them.

The argument order changes

As with the SUM pair, the range to average is last in AVERAGEIF and first in AVERAGEIFS.

AVERAGEIFS works with a single condition too, so you can use it always and remember one order.

Conditions

They are written exactly as for SUMIF.

ConditionMeaning
"8A"equal to the text 8A
">=50"50 or more
"<>0"not zero
H1equal to the value in H1
">"&H1greater than the value in H1
"A*"text starting with A

Leaving out zeros

A common need is the average of the values that are not zero, because a zero means "no sale" or "not entered": =AVERAGEIF(F2:F13,"<>0"). With no third argument, the tested cells are the ones averaged.

The empty group

When no row meets the condition there is nothing to average, and the result is #DIV/0!. That is not a mistake in your formula. It is Excel saying it cannot divide by zero rows. In a report, wrap the formula in IFERROR to show a dash or a message, as in the last example.

Blanks in the range being averaged

Empty cells in the average range are skipped, as with AVERAGE. A student with a blank mark does not pull the group's average down. If blanks should count as zero, divide SUMIF by COUNTIF instead, or fill in the zeros.

A small summary table

List the classes in a column, say H2 downwards, and write once:

=AVERAGEIF($B$2:$B$9,H2,$C$2:$C$9)

Copy it down. The dollar signs hold the data ranges still while H2 moves to each class in turn.

Common mistakes

In Google Sheets

AVERAGEIF and AVERAGEIFS are the same in Google Sheets.

Related functions

Every result on this page was calculated in Microsoft Excel (version 16.0, build 20326) on 12 November 2026, not typed by hand.

This is an independent help site. It is not connected with or approved by Microsoft. Excel and Microsoft 365 are trademarks of Microsoft Corporation, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.