Excel Formula Tables: How to Exclude Zeros
In this article
To exclude zeros from an Excel formula table, wrap your original formula in an IF test that returns an empty string instead of zero, such as =IF(SUMIFS(D:D,A:A,F2)=0,"",SUMIFS(D:D,A:A,F2)). That single change hides zero results from a lookup or summary table. For averages that should ignore zeros, use AVERAGEIF or AVERAGEIFS with a criterion of "<>0" so the zero rows are skipped entirely. For tables built from a PivotTable, filter the value field instead of rewriting formulas.
What You'll Need
- A recent version of Excel in Microsoft 365, Excel 2021, 2019 or 2016 for Windows or Mac. The named functions used here (SUMIFS, AVERAGEIFS, COUNTIFS, FILTER) are not available in Excel 2010 or earlier.
- A source range of data with at least one text column (a label such as a product or region) and one numeric column containing values, some of which are zero.
- An empty area of the sheet where the summary table will sit, separate from the raw data so formulas do not overwrite rows.
- Consistent column layout. Each formula below assumes headers are in row 1 and data runs from row 2 down. Adjust the row references to match your own sheet.
Step-by-Step
Decide what "excluding zeros" should mean in your case. There are two different goals, and they need different formulas. Goal one is to hide a zero result so the table cell looks empty. Goal two is to leave a real zero in the data out of an average, a count or a filtered list. Write down which one you need before touching a formula, because mixing the two is the most common source of wrong totals.
Hide zero results with an IF wrapper. If you have a lookup or aggregation formula like =SUMIFS($D$2:$D$500,$A$2:$A$500,$F2), wrap it: =IF(SUMIFS($D$2:$D$500,$A$2:$A$500,$F2)=0,"",SUMIFS($D$2:$D$500,$A$2:$A$500,$F2)). The cell now shows nothing when the result is zero and the normal value otherwise. The double quotes with nothing between them produce an empty string rather than a formatted zero. Copy the formula down the label column so the whole table inherits the behaviour.
Skip zero rows in an average with AVERAGEIF. Use =AVERAGEIF($D$2:$D$500,"<>0") to average every non-zero number in the column. To average only the rows matching a label, use =AVERAGEIFS($D$2:$D$500,$A$2:$A$500,$F2,$D$2:$D$500,"<>0"). The final criterion is what excludes the zeros; without it, zero sales days pull the average down and make the result look worse than the business really is. Note that AVERAGEIF ignores blank cells automatically, so you only need to handle literal zeros.
Count only non-zero entries. =COUNTIFS($A$2:$A$500,$F2,$D$2:$D$500,"<>0") returns the number of rows for that label where the value is not zero. If you also want to exclude blanks at the same time, the criterion "<>0" already does that, because a truly empty cell is not greater than or less than zero. If a cell contains a formula returning an empty string, though, COUNTIFS may still count it, so pair it with a COUNTIF on the same range if the numbers do not reconcile.
Build a clean list with FILTER. On Microsoft 365 and Excel 2021, =FILTER($A$2:$D$500,$D$2:$D$500<>0,"No records") spills every row where the value is not zero, and shows the message "No records" if everything is zero or blank. This is the fastest way to get a table that physically contains no zero rows. Leave plenty of empty space below the formula, because the results spill downward and to the right and will show a #SPILL! error if anything is in the way.
Or use a PivotTable filter. Select the data, then choose Insert > PivotTable and confirm the range and destination. Drag the label column into Rows and the numeric column into Values. Excel adds a filter arrow to the row header; open it, go to Value Filters, and set the rule to exclude zero, for example "does not equal 0" on the Sum of the value field. The PivotTable then omits zero groups without any formula at all, and it updates when you refresh. Menu wording varies slightly by Excel version and region.
Format the empty results so they do not look broken. Cells returning "" are text, not numbers, so a currency format applied to them does nothing and right-aligned numbers may suddenly look left-aligned. Select the table column and set an alignment of your choice, or use conditional formatting with a rule for blank or empty text to apply light grey font. Do not try to multiply or sum those cells afterwards, because text values are ignored by SUM and can cause #VALUE! errors in plain arithmetic.
Check the totals reconcile. Compare the sum of the visible table values against the sum of the whole source column. If they differ and you expected them to match, you have mixed the two goals from step one: hiding a zero for display is fine, but a real zero must still be included in a total unless you deliberately excluded it. Document the choice in a note cell or a header comment so the next person editing the sheet does not "fix" it by accident.
Common Mistakes
- Comparing text to zero. If a value arrived from a CSV import or a web export it may be stored as text. "0" (text) is not equal to 0 (number), so the IF test misses it and you still see zeros. Use VALUE() or multiply by 1 to convert, or use Data > Text to Columns to force the column to numbers.
- Relying on a custom number format. Formatting a cell with a format like 0;-0;;@ hides zeros on screen but leaves the number in the cell. Charts, copied values and downstream formulas still see the zero. Use it as a display trick only, not as a data fix.
- Forgetting the anchors. Without the dollar signs in $D$2:$D$500, dragging the formula down shifts the ranges and you end up averaging the wrong rows. Lock the range references before copying.
- Wrapping a whole array in IF unnecessarily. In modern Excel, FILTER already handles exclusions cleanly and returns a dynamic range you can reference directly. Wrapping spilled arrays in IF(...,"") can produce confusing results.
- Ignoring negative numbers. A criterion of "<>0" excludes only exact zeros. If your data contains refunds or adjustments as negative values, they are still included, which is usually correct but worth confirming.
Tips
- Convert your source range to an Excel Table (Ctrl+T on Windows, Command+T on Mac) and formulas that reference the table name grow automatically as rows are added, so you never have to rewrite the ranges.
- Use a helper cell for the criterion (such as a cell containing the text <>0) if you want to switch the exclusion on and off without editing formulas.
- Put the label list in the summary table in a separate column and reference it with absolute references, so each row of formulas only differs by one relative cell.
- If you only need to stop a chart plotting zero gaps, right-click the series, open Select Data, choose Hidden and Empty Cells, and set how blanks and zeros are plotted.
Troubleshooting
- You still see 0 in the cell. Confirm the formula actually returns a numeric zero and not text. Select the cell, look at the formula bar, and use the Evaluate Formula tool under Formulas to step through it. If the value is text, "<>0" will not exclude it.
- You get #SPILL!. Something sits in the cells the FILTER result needs. Clear the range below and to the right of the formula, or move the formula to an empty area.
- You get #VALUE!. A text value is being used in arithmetic. Check the source column for stray spaces, apostrophes or imported text, and clean it before averaging.
- The average looks too high. Manually check a small sample. If a row is blank rather than zero, AVERAGEIFS already skips it, so the difference is usually a genuinely excluded zero you meant to keep.
- The PivotTable still lists zero groups. Value filters apply to the sum, not to individual rows, so a group with equal positive and negative entries can still appear. Refresh the PivotTable after changing the source data.
Frequently Asked Questions
Does AVERAGEIF ignore zeros automatically?
No. AVERAGEIF and AVERAGEIFS include zeros unless you add a criterion of "<>0" for the same range. Blank cells are ignored automatically.
Can I hide zeros across an entire sheet instead of one table?
Yes. Open File > Options > Advanced, scroll to the section for this worksheet, and clear the checkbox that shows zero values. This hides display only; the underlying numbers remain and formulas still use them.
Why does my IF formula return a blank but the sum still counts zero?
Because the sum is reading the source column, not your display column. Excluding zeros in the table does not change the raw data, so totals based on the source remain the same.
Which Excel versions support FILTER?
Microsoft 365 and Excel 2021 and later. On older versions, use a helper column with an IF, then AutoFilter or sort to hide the rows returning blank.
Can SUMIFS exclude zero rows directly?
SUMIFS will add zeros, but adding them changes nothing, so exclusion is only meaningful for averages, counts, lists or lookups. For display, wrap the result in an IF test instead.