Cal11 calculator

Excel Calculate Average But Ignore 0

Reviewed by Calculator Editorial Team

When calculating averages in Excel, you may need to exclude zero values from the calculation. This guide explains how to do this properly, including the correct formula and practical examples.

How to Calculate Average Ignoring 0 in Excel

Calculating an average while ignoring zero values is a common requirement in data analysis. Excel provides several methods to achieve this, each with its own advantages depending on your data structure and needs.

Method 1: Using AVERAGEIF Function

The simplest method is to use the AVERAGEIF function, which calculates the average of cells that meet a specified condition. To exclude zeros:

Formula: =AVERAGEIF(range, ">0")

Where "range" is the cell range containing your data. This function will automatically ignore any zero values in the calculation.

Method 2: Using SUMPRODUCT and COUNTIF

For more complex scenarios, you can use a combination of SUMPRODUCT and COUNTIF functions:

Formula: =SUMPRODUCT(range)/(COUNTIF(range, ">0"))

This method gives you more control over the calculation process and can be adapted for more complex conditions.

Method 3: Using PivotTables

For large datasets, creating a PivotTable is an effective solution. You can:

  1. Select your data range
  2. Go to Insert > PivotTable
  3. In the PivotTable Fields pane, add your data field to both the Values and Rows areas
  4. Right-click on the data field in the Values area and select "Value Field Settings"
  5. Choose "Average" and check "Show values as" > "Average"

This will automatically exclude zero values from the average calculation.

Excel Formula for Average Ignoring 0

The most straightforward formula to calculate an average while ignoring zero values is:

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

This formula will calculate the average of all non-zero values in the range A1:A10. You can adjust the range to match your data.

Note: The AVERAGEIF function will return the #DIV/0! error if all values in the range are zero. To handle this, you can use the IFERROR function:

=IFERROR(AVERAGEIF(A1:A10, ">0"), "All values are zero")

Worked Example

Let's look at a practical example to see how this works in Excel.

Sample Data

Cell Value
A1 10
A2 20
A3 0
A4 30
A5 0
A6 40

Calculation

Using the formula =AVERAGEIF(A1:A6, ">0"), Excel will:

  1. Identify all non-zero values (10, 20, 30, 40)
  2. Sum these values (10 + 20 + 30 + 40 = 100)
  3. Count the number of non-zero values (4)
  4. Divide the sum by the count (100 ÷ 4 = 25)

The result is 25, which is the average of the non-zero values in the range.

FAQ

How do I calculate an average excluding zeros in Excel?
Use the AVERAGEIF function with the condition ">0". For example: =AVERAGEIF(A1:A10, ">0")
What if all values in my range are zero?
The AVERAGEIF function will return a #DIV/0! error. You can use IFERROR to handle this case: =IFERROR(AVERAGEIF(A1:A10, ">0"), "All values are zero")
Can I use this formula with multiple columns?
Yes, you can apply the same formula to multiple columns by adjusting the range. For example: =AVERAGEIF(B1:B10, ">0")
Is there a way to exclude both zeros and negative numbers?
Yes, modify the condition to ">0" to exclude both zeros and negative numbers: =AVERAGEIF(A1:A10, ">0")
Can I use this formula in a PivotTable?
Yes, you can create a calculated field in a PivotTable that uses the AVERAGEIF function to exclude zeros.