Cal11 calculator

Calculate Average in Excel Ignore 0

Reviewed by Calculator Editorial Team

Calculating an average in Excel while ignoring zero values is a common requirement in data analysis. This guide explains how to do it efficiently, provides the necessary Excel formula, and includes a practical calculator to help you verify your results.

How to Calculate Average in Excel Ignoring 0

When working with datasets that include zero values, you may want to calculate the average of only the non-zero values. Excel provides several methods to achieve this:

Method 1: Using COUNTIF and SUMIF

The most straightforward approach is to use the COUNTIF function to count the non-zero values and the SUMIF function to sum those values. Then divide the sum by the count to get the average.

=SUMIF(A1:A10, ">0", A1:A10)/COUNTIF(A1:A10, ">0")

Method 2: Using AVERAGEIF

Excel's AVERAGEIF function simplifies this calculation by combining the counting and summing steps into one function.

=AVERAGEIF(A1:A10, ">0")

Method 3: Using SUMPRODUCT

For more complex scenarios, you can use the SUMPRODUCT function with logical conditions to calculate the average while ignoring zeros.

=SUMPRODUCT(A1:A10, --(A1:A10>0))/SUMPRODUCT(--(A1:A10>0))

Note: All these methods will return the same result when applied to the same dataset. Choose the one that best fits your specific needs and Excel version.

Excel Formula

The most commonly used formula for calculating an average while ignoring zeros is the AVERAGEIF function:

=AVERAGEIF(range, criteria)

Where:

  • range - The range of cells you want to average
  • criteria - The condition that specifies which values to include (e.g., ">0" to exclude zeros)

For example, if your data is in cells A1 to A10, the formula would be:

=AVERAGEIF(A1:A10, ">0")

Worked Examples

Example 1: Simple Dataset

Consider the following dataset in cells A1 to A5:

Value
10
0
20
0
30

The average of non-zero values is calculated as:

(10 + 20 + 30) / 3 = 20

Example 2: Larger Dataset

For a dataset with more values, the formula still applies. For example, with values 5, 0, 10, 0, 15, 0, 20:

(5 + 10 + 15 + 20) / 4 = 12.5

FAQ

What if my data contains negative numbers?
The formulas provided will work with negative numbers as well. The ">0" condition will exclude both zeros and negative numbers. If you want to exclude only zeros but include negative numbers, you can use "<>0" as the criteria.
Can I use this formula with non-numeric data?
No, the AVERAGEIF function only works with numeric data. If your range contains text or other non-numeric values, you'll need to clean your data first or use a different approach.
Is there a way to calculate the average of non-zero values in a specific column?
Yes, you can apply the formula to a specific column by specifying the column range. For example, to average non-zero values in column B, use =AVERAGEIF(B:B, ">0").
What if all values in my range are zero?
If all values are zero, the formula will return the #DIV/0! error because you're trying to divide by zero. You can handle this by adding an IFERROR function to return a custom message or value.