Consulting

Results 1 to 7 of 7

Thread: CHART Challenge: Plot NA# as null values

  1. #1
    VBAX Expert
    Joined
    Dec 2007
    Posts
    522
    Location

    CHART Challenge: Plot NA# as null values

    Hi All,

    I have a chart challenge.

    In the sample workbook, I have the following sample (made up) dataset.

    x-axis y-axis 1 1234 2 3124 3 32 4 235 5 #N/A 6 #N/A 7 #N/A 8 #N/A 9 25

    When line chart x-vs-y, in the workbook, It plots 1-4 correctly and then smooths a line through x values 5-9.

    I would like it to not plot these NA# values at all and have a gap inbetween points 5-8 (inclusive).

    If anybody could explain how to do this without manually altering the chart line, but by altering the chart settings or conditional formatting, I would be really grateful.

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I don't have 2007. In 2003 I use ISNA to get around that problem.

    I read this about 2007 however which might help with your problem:


    In Excel 2007, the IFERROR function was introduced, which allows you
    to specify a value to return if a formula returns an error. E.g,
    [VBA]
    =IFERROR(VLOOKUP(...),0)
    [/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    reply I gave to a similar question on another forum.

    For a line #N/A will only remove the data marker.

    The line will be interpolated for #N/A using the nearest real data values to the left and right. This means a line can be truncated by using #N/A but you can not create gaps. Only true empty cells will create gaps.
    This over rides the settings of Leave Gaps, Interpolate and As Zero. Those settings only apply to empty cells.

    If your data is not too complicated you can try
    http://www.andypope.info/charts/brokenlines.htm

    Otherwise VBA to clear the cells is the only other option.

    Or I guess you could use multiple series to plot the segments.
    Cheers
    Andy

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Might be close enough for you if can make the missing data blank or 0, instead of N/A

    Select chart, Chart Tools, Design, Data Source, Hidden and Empty Cells, and select 'Show Empty Cells as Gaps"

    Attached sample


    Paul
    Last edited by Paul_Hossler; 12-16-2009 at 06:32 AM.

  5. #5
    VBAX Expert
    Joined
    Dec 2007
    Posts
    522
    Location
    Hi Paul and Andy and Steve,

    First of sincere thanks for the kind and helpful replies.

    I was unable to reply to you all as I travelled overseas and have had great difficulty in accessing the internet (I am writing this from a netcafe).

    Andy, your solution is a very clever workaround for the problem, though difficult for me to implement due to insufficient columns in the spreadhseet template, though I may revisit this if i can modify the already built template.

    Paul your solution sounds great, though the one issue is that I can't blank these cells (i.e. actually clear them) but can set them to "" or a 0 value as you suggested.

    In both cases it appears to plot the "missing" values as 0 values with your solution, which is better than the current interpolation that is occurring, so kudos for suggesting this. If you do the same, do you see the values plotted as zeroes or genuine gaps?

    Also, is there a way to have workbook event code to apply the setting you have suggested to every chart in the workbook that would work in Excel 2003 or Excel 2007?

    Many thanks for your kind help.

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    I used the option to leave as gaps

    Paul

  7. #7
    Lucas,
    Quote Originally Posted by lucas
    I don't have 2007. In 2003 I use ISNA to get around that problem.
    How?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •