Have you ever seen a line chart in Excel that’s suddenly dropping to zero? Here’s why it happens and what to do about it:
Let’s say you have a table where you enter new sales figures every day, and a line chart connected to it. The sales figures for the last few days in the table have not yet been filled out, so the last values for the y-axis are zero. This is what the line chart could look like:
How can we get rid of this vertical line that appears after the last data entry?
The y-axis gets its data from column D, Total Revenue, which is the product of Units Sold and Price per Unit (=B2*C2, copied down). As long as we don’t have any entries for the last six days, the Total Revenue for these days would be zero. To Excel, it looks like the sales suddenly dropped from $144 to $0 overnight.
One way to solve this is to replace the zeros with #N/A. The #N/A message usually appears in lookup queries such as VLOOKUP, MATCH etc. when you search for a non-existing value, but that’s not the case here, so we have to cheat!
We’ll use a simple IF-statement in column D: IF UnitsSold = 0, then return #N/A, if not, return TotalRevenue. In Excel syntax:
…and copy down.
Note: If you have an older version of Excel, the NA() function won’t work. Try this instead: =IF(B2=0,#N/A,B2*C2)
More on tables and charts:
- How and Why you should use a Logarithmic Scale in an Excel Diagram
- 5 Easy Steps to Make Your Excel Charts Look Professional
- How to Add All the Sums into an Excel Table in a Second
- Highlight an Entire Row in Excel Based on One Cell Value
Are you using a non-English version of Excel? Click here for translations of the 140 most common functions in 17 different languages: