To stop zero values from appearing in an Excel bar chart, you must replace the zeros in your data source with the #N/A error using the IF and NA functions. Excel treats a zero as a numerical value and plots it as a flat line or a label on the axis, but it ignores #N/A values entirely when rendering chart elements, effectively hiding them from view.
What You'll Need
- A Microsoft Excel spreadsheet containing a data table.
- A bar or column chart already created from that data.
- Basic familiarity with entering formulas into cells.
Step-by-Step
- Create a Helper Column: Do not apply formulas directly to your raw data if you need to keep the zeros for accounting or calculation purposes. Instead, create a new "Chart Data" column next to your original data.
- Enter the NA Formula: In the first cell of your helper column, enter a formula that checks if the original value is zero. For example, if your data is in cell A2, use:
=IF(A2=0, NA(), A2). (Note: Menu labels and function behavior may vary slightly depending on your version of Excel). - Apply the Formula to All Rows: Click the bottom-right corner of the cell containing the formula and drag it down to cover all the rows in your dataset. You will now see
#N/Aappearing wherever there was previously a zero. - Update the Chart Data Source:
- Right-click anywhere on your existing bar chart.
- Select Select Data... from the context menu.
- In the Legend Entries (Series) section, click Edit.
- Change the Series values range to point to your new helper column instead of the original data column.
- Click OK and then OK again.
- Hide #N/A Labels (Optional): If your chart uses data labels, the #N/A error might still show as text. To fix this, right-click the cells in your helper column, select Conditional Formatting > New Rule > Format only cells that contain. Set the rule to Errors and change the font color to white to make them invisible in the spreadsheet.
Common Mistakes
- Deleting the Zeros: Simply deleting the zero or leaving the cell blank often results in Excel treating the value as zero anyway, meaning the gap or the flat bar remains in the chart.
- Using Empty Strings: Using a formula like
=IF(A2=0, "", A2)returns a text string. Excel often interprets empty strings as zeros in charts, which fails to remove the zero-value bars. - Editing Raw Data: Changing zeros to #N/A in your primary data table can break other formulas (like SUM or AVERAGE) that rely on those cells. Always use a helper column for chart-specific formatting.
Tips
- Dynamic Ranges: If your data grows over time, convert your data range into an official Excel Table (Ctrl + T). This ensures that your helper column formulas and your chart range expand automatically when you add new rows.
- Filtering: If you want to remove the entire category (the label on the axis) rather than just the bar, use the Filter tool on your data table to uncheck "0". The chart will automatically hide any row that is filtered out of the sheet.
- Chart Types: The #N/A method works best for bar and column charts. For line charts, #N/A prevents the line from dropping to the zero axis, though you may need to adjust "Hidden and Empty Cell Settings" in the Select Data menu to choose whether to connect data points with a line or leave a gap.
Troubleshooting
If the zero values are still appearing after following these steps, try the following in order:
- Check for "Hidden" Decimals: Ensure the value is exactly 0. If a cell contains 0.001 but is formatted to show zero decimals, Excel sees it as a positive number and will plot a tiny bar. Use the
ROUNDfunction in your IF statement to handle near-zero values. - Verify Data Range: Go back to Select Data... and double-check that the Series values are pointing to the helper column and not the original column.
- Refresh the Chart: Sometimes Excel doesn't trigger a redraw immediately. Try clicking on the chart area or pressing F9 to recalculate the workbook.
- Check for Text Formatting: Ensure your numbers are formatted as "Number" or "General" and not as "Text," as formulas may not evaluate text-based zeros correctly.
Frequently Asked Questions
Will using #N/A affect my other calculations?
Yes, if you use the helper column in other formulas. Any standard math function (like SUM) that encounters an #N/A will return #N/A. To avoid this, keep your raw data and your chart data in separate columns.
Can I hide zeros without using a helper column?
Not entirely. You can change the number formatting of the cells to 0;-0;;@ to make zeros invisible in the cells, but the bar chart will still plot the zero value because the underlying data is still there.
How do I get rid of the #N/A symbols in my spreadsheet?
The best way is using Conditional Formatting to turn the font white if the cell contains an error, or by using the IFERROR function in a separate display layer, though the chart specifically requires the #N/A error to hide the bar.
Does this work for Pie Charts?
Yes, using the #N/A method in the data source will prevent zero-value slices from appearing in the pie chart legend and the chart itself.
What is the difference between a blank cell and #N/A?
A blank cell is often interpreted by Excel as a zero depending on your chart settings. #N/A is a specific error code that tells Excel "there is no data here," which forces the chart to skip that point entirely.