fxExcelReps
← All functions ∑? Conditional sums & counts · Intermediate

AVERAGEIF Average only the rows that match.

How to use AVERAGEIF in Excel

AVERAGEIF averages only the values that meet a condition — average order value per city, average score per class.

Syntax

=AVERAGEIF(range, criteria, [average_range])

rangeThe cells to check.
criteriaThe condition.
[average_range]The cells to average. If omitted, range is averaged.

Examples

=AVERAGEIF(B2:B100, "Laptop", C2:C100)Average laptop sale.
=AVERAGEIF(C2:C100, ">0")Average excluding zeros.
=AVERAGEIFS(C2:C100, A2:A100, "Varna", B2:B100, "Phone")Several conditions with AVERAGEIFS.

Average by category: a summary in one column

Put the categories in a list, point the criteria at the first one and copy the formula down. Lock both ranges with $.

=AVERAGEIF($B$2:$B$500, F2, $D$2:$D$500)The average loan amount for the branch in F2.
=ROUND(AVERAGEIF($B$2:$B$500, F2, $D$2:$D$500), 0)The same, rounded to whole units for a report.

Leave out zeros and blanks

AVERAGE counts zeros, so a few empty months filled with 0 pull the result down. A condition of ">0" averages only the real values.

=AVERAGEIF(C2:C13, ">0")The average monthly balance, ignoring months with no data.
=AVERAGEIF(C2:C13, "<>0")The same, but negative values still count.

Average between two dates

AVERAGEIF takes only one condition. For a date range, switch to AVERAGEIFS and use the date column twice.

=AVERAGEIFS(D2:D500, A2:A500, ">="&G1, A2:A500, "<="&G2)The average amount between the dates in G1 and G2.

Common mistakes

#DIV/0! error
No row matches the condition. Wrap with IFERROR.
Several conditions
Use AVERAGEIFS — like SUMIFS, the average range comes first.

Frequently asked questions

What's the difference between AVERAGEIF and AVERAGEIFS?

AVERAGEIF takes one condition and puts the range to average last. AVERAGEIFS takes up to 127 conditions and puts the range to average first.

Why does AVERAGEIF return #DIV/0!?

No cell matches the condition, so there's nothing to average. Show a message instead: =IFERROR(AVERAGEIF(B2:B500, F2, D2:D500), "No data").

Does AVERAGEIF ignore blank cells?

Yes, blanks and text in the range to average are skipped. Zeros are not: use ">0" as the condition when 0 means "no data".

Can AVERAGEIF use wildcards?

Yes. =AVERAGEIF(A2:A500, "*Ltd*", D2:D500) averages every client with "Ltd" anywhere in the name.

Available in: All versions of Excel, Excel for the web, Google Sheets

Related functions

SUMIFCOUNTIFAVERAGESUMIFS

↑ Practise AVERAGEIF in the sheet above