Excel Chart Ignore Zero Values: How to Hide Zeros
In this article
To make an Excel chart ignore zero values, you must replace the zeros in your data source with the #N/A error using the formula =NA(). Excel is designed to plot numerical zeros as data points on the axis, but it treats #N/A (Not Available) as a missing value, which prevents the line from dropping to the zero baseline in line charts or showing empty bars in column charts.
What You'll Need
- Microsoft Excel (Desktop version for Windows or macOS)
- A dataset containing numerical values and zeros that you wish to hide from a chart
- A basic understanding of how to enter formulas in Excel cells
Step-by-Step
Depending on whether your zeros are hard-coded or the result of a formula, you will use one of the following methods. Note that menu labels may differ slightly based on your version of Excel or regional settings.
Method 1: Using the =NA() Formula (Best for Line Charts)
- Identify the range of cells in your spreadsheet that contains the zero values you want to hide.
- Create a helper column or modify your existing formula to incorporate an IF statement. For example, if your original data is in cell A1, use the formula:
=IF(A1=0, NA(), A1). - Drag the fill handle (the small square at the bottom-right of the cell) down to apply this formula to all relevant rows in your dataset.
- You will now see
#N/Aappearing in cells where the value was previously zero. - Select your data range, including these #N/A values, and insert your chart (Insert > Recommended Charts > Line Chart).
- Right-click on the data series (the line) within the chart and select Format Data Series.
- In the Format Data Series pane, click on the Fill & Line icon (the paint bucket).
- Scroll down to the Hidden and Empty Cells section (if not visible, you may need to access this via the Chart Design tab > Select Data > Hidden and Empty Cells).
- Select the option Connect data points with line. This ensures that the chart skips the #N/A gaps and connects the surrounding valid data points, rather than dropping the line to zero or leaving a blank gap.
Method 2: Using Custom Number Formatting (Best for Bar/Column Charts)
If you want the zeros to remain as zeros for calculation purposes but simply want them to disappear from the chart's visual representation or the data table, use custom formatting.
- Highlight the cells in your data table that contain the zeros.
- Right-click the selection and choose Format Cells, or press
Ctrl + 1(Windows) /Cmd + 1(Mac). - In the Number tab, select Custom from the Category list on the left.
- In the Type input box, enter the following code:
0;-0;;@. - Click OK. The zeros will now be invisible in the spreadsheet cells.
- When you create a Column or Bar chart from this data, the cells with zeros will not produce a visible bar, effectively ignoring the zero values while keeping the actual numeric data intact for your sums and averages.
Method 3: Filtering Out Zeros
- Select the header row of your data table.
- Go to the Data tab and click the Filter button.
- Click the filter dropdown arrow in the column containing the zeros.
- Uncheck the box next to 0 and click OK.
- Excel charts are programmed by default to ignore hidden rows. As a result, the zero values will be removed from the chart automatically.
Common Mistakes
One of the most frequent errors is attempting to simply delete the zero or leave the cell blank. In many Excel chart types, a blank cell is treated as a zero by default, meaning the line will still plunge to the bottom of the axis. This is why the =NA() function is critical; it tells Excel that the data is truly missing, not just zero.
Another common mistake is applying custom formatting to the chart axis rather than the source data. Custom formatting the axis only changes how the numbers look on the scale; it does not remove the data points from the plot area. To remove the visual representation of the zero, you must modify the source data or the series settings.
Users also often forget to change the "Hidden and Empty Cells" setting after using the #N/A method. Without selecting "Connect data points with line," your line chart will have unsightly gaps where the zeros used to be, which can make the data look fragmented and unprofessional.
Tips
If you find the #N/A errors distracting in your spreadsheet, you can use Conditional Formatting to hide them. Select the range, go to Home > Conditional Formatting > New Rule > Format only cells that contain. Set the cell value to Errors and set the font color to white. This keeps the chart functioning correctly while making the spreadsheet look clean.
For those working with large datasets, consider converting your data range into an official Excel Table (Ctrl + T). When you use a Table, any formulas you write (like the IF/NA formula) are automatically applied to new rows as you add data, ensuring your chart remains updated and continues to ignore zeros without manual intervention.
If you are using a Scatter Plot, remember that #N/A values will simply not be plotted. This is often the desired effect, as it prevents the plot from being cluttered with points at the origin (0,0) that do not represent actual experimental or business results.
Troubleshooting
The line still drops to zero even after using =NA().
Check your "Hidden and Empty Cells" settings. Go to Chart Design > Select Data > Hidden and Empty Cells. Ensure that the setting is not set to "Gaps" or "Zero." If the line is still dropping, double-check your formula; ensure you are using NA() and not typing the text "#N/A" manually. The function =NA() produces a specific error type that Excel recognizes; typing the text does not.
The custom format 0;-0;;@ is not hiding my zeros.
Ensure your cells are formatted as Numbers and not as Text. If the zero was entered as text (e.g., with an apostrophe before the number), custom number formatting will not work. Use the VALUE() function or the "Convert to Number" warning to fix the data type first.
My filter is hiding too much data.
If you have multiple columns and only want to ignore zeros in one, ensure you are only filtering the specific column that affects the chart's Y-axis. If you filter a category column, you may accidentally remove entire time periods or groups from your chart.
Frequently Asked Questions
Will using =NA() mess up my SUM or AVERAGE formulas?
Yes, standard formulas like =SUM() and =AVERAGE() will return an #N/A error if any cell in the range contains #N/A. To fix this, use the =AGGREGATE() function or =SUMIF() to ignore error values in your calculations.
Can I hide zeros without adding a helper column?
You can use the Filter method or Custom Formatting to hide the visual appearance of zeros. However, to truly make a line chart "skip" a point without dropping to the axis, a helper column with =NA() is the most reliable method.
Does this work in Excel Online (Web version)?
Most of these features, including the =NA() function and Custom Formatting, work in Excel Online. However, the "Hidden and Empty Cells" menu may be located in different positions or have limited options compared to the desktop application.
Why does Excel treat blanks as zeros?
By default, Excel interprets a blank cell in a data series as a zero to maintain the continuity of the data range. You can change this behavior in the "Select Data" settings, but using #N/A is more explicit and prevents ambiguity in your data reporting.
Can I use a different character instead of #N/A?
For the purpose of the chart's logic, no. Excel specifically looks for the #N/A error to trigger the "missing data" behavior. Using a dash, a space, or a word like "None" will either be treated as a zero or cause the chart to break entirely.