How-to recipes · Analysis

How to average ignoring zeros in Excel

Calculate an average that skips zero values with AVERAGEIF, AVERAGE + FILTER in Microsoft 365, and handle blanks, errors and all-zero ranges.

Beginner AVERAGEIF AVERAGEIFS AVERAGE FILTER AGGREGATE IFERROR

A shop records daily sales, and on days when it is closed the sheet shows 0. A machine log has 0 for hours when the machine was switched off. A grade book has 0 for tests that have not been taken yet. If you calculate the AVERAGE of such a column, the zeros pull the result down and the average no longer describes a normal day. You want the average of the real values only. This recipe shows how, and explains the difference between zeros and empty cells, which Excel treats very differently.

The example data

Sales for six days in A1:B7. The shop was closed on Tuesday and Friday, so those days show 0. The plain average is 621.67, but the average of the four trading days is 932.5.

Every version: AVERAGEIF with "<>0"

B9fx=AVERAGEIF(B2:B7,"<>0")
AB
1DaySales
2Mon820
3Tue0
4Wed760
5Thu910
6Fri0
7Sat1240
8
9932.5

(820 + 760 + 910 + 1240) / 4 = 932.5

Result: 932.5

AVERAGEIF averages only the cells that meet a condition. "<>0" means not equal to zero. Because AVERAGEIF also ignores empty cells and text, it averages exactly the four trading days.

If the column can also contain negative numbers (refunds, losses) that you want to keep, "<>0" is the right condition. If only positive values make sense, ">0" is equivalent and also excludes negatives.

Microsoft 365: AVERAGE + FILTER

FILTER removes the zeros and AVERAGE does the rest:

Formula
=AVERAGE(FILTER(B2:B7,B2:B7<>0))

It returns 932.5 too. This style is useful when the condition is more complex than AVERAGEIF can express, for example ignoring zeros and Saturdays: =AVERAGE(FILTER(B2:B7,(B2:B7<>0)*(A2:A7<>"Sat"))).

Zeros with another condition

Use AVERAGEIFS when you also need a condition on another column, for example the average of non-zero sales for one store in a longer list:

Formula
=AVERAGEIFS(C2:C100,C2:C100,"<>0",A2:A100,"Store 3")

In AVERAGEIFS the range to average comes first, followed by pairs of criteria range and criterion. The same column can be both the average range and a criteria range.

Zeros versus blank cells

Cell containsAVERAGEAVERAGEIF(...,"<>0")
A number, e.g. 820includedincluded
0includedignored
Empty cellignoredignored
Text such as closedignoredignored
Formula returning ""ignoredignored

This shows a better long-term fix: if a value is missing rather than truly zero, leave the cell empty or have the formula return "" instead of 0, and the plain AVERAGE already does the right thing. A formula like =IF(C2="","",C2*D2) keeps missing rows out of averages.

Tip. If zeros should be hidden from view but stay in the cells, use the number format 0;-0;;@, which displays nothing for zero. The cell still contains 0, so AVERAGE still counts it; the display format does not change the calculation.

When every value is zero

If all cells are 0 (for example a store that has not opened yet), there is nothing to average and AVERAGEIF returns #DIV/0!. Wrap it in IFERROR to show something friendlier: =IFERROR(AVERAGEIF(B2:B7,"<>0"),"No sales yet"), or return 0 if the result feeds another calculation.

Ignoring errors as well

If some cells contain errors such as #N/A from a lookup, AVERAGE and AVERAGEIF both return the error. AGGREGATE with option 6 ignores errors: =AGGREGATE(1,6,B2:B7) averages while skipping errors, but it still counts zeros. To skip both, use =AVERAGE(FILTER(B2:B7,IFERROR(B2:B7<>0,FALSE))) in Microsoft 365.

Pitfalls

  • Numbers stored as text are ignored by all averaging functions. A column of imported values can give a suspiciously small or #DIV/0! result; check with =COUNT(B2:B7).
  • Near-zero values such as 0.0001 from a rounding difference are not equal to 0 and are kept. Round the source values if that matters.
  • Hiding vs excluding. The custom format tip above only hides zeros; it does not exclude them from the average.
  • Ignoring zeros changes the meaning. Average sales per trading day and average sales per calendar day are both valid measures; label which one you report.

Related recipes: How to calculate a weighted average in Excel for averages where some values count more, and Counting and summing with criteria: COUNTIFS, SUMIFS, SUMPRODUCT for the whole family of IF/IFS functions.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 12 KB

More how-to recipes