+ Reply to Thread
Results 1 to 7 of 7

Hide legend items in a graph when associated value = zero or blank

  1. #1
    Registered User
    Join Date
    01-16-2013
    Location
    Oakland, CA
    MS-Off Ver
    Excel 2010
    Posts
    22

    Question Hide legend items in a graph when associated value = zero or blank

    I have a graph which picks up Legend Items from column C and percentages from column E. I don't want to delete the rows of information from column C and E where they are blank, as they might be used as process grows. But I don't want these items to appear in the Pie Chart if percentages are zero.

    I've tried clearing any data from those cells, that doesn't work. I end up with an icon for the color within the legend, with no name next to it. I'd like it to not show at all if percentages are zero.

    I've attached a sample Excel file, and I've highlighted the row information in Yellow that I would like to no show in the graph.

    I'm setting this up for others, and trying to automate it as much as possible, so if there is a way to do this so it just happens automatically whenever percentage = zero....that would be incredible!!!

    Thanks for any help!

    - Ben
    Attached Files Attached Files

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Hide legend items in a graph when associated value = zero or blank

    hi Ben. this is a little tedious.
    1. do up a separate table with formulas to pick up only those values greater than 0. i used an array formula in G2:
    =IFERROR(INDEX($C$2:$C$16,SMALL(IF($D$2:$D$16>0,ROW($D$2:$D$16)),ROWS(G$2:G2))-ROW($D$2)+1),"")
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you might get an error or a clearly incorrect answer. Press F2 on that cell and try again.

    2. do a VLOOKUP formula in H2:
    =IFERROR(VLOOKUP($G2,$C$2:$E$16,3,0),"")

    3. this formula below will intelligently pick up the new range i have without the blanks:
    =$G$2:INDEX($G$2:$G$16,COUNTIF($G$2:$G$16,">"""))

    4. i need to store the formula in step 3 under a Named Range. to do that, press CTRL + F3 -> New. give it a Name & insert the formula of step 3. (shown in screenshot inside file). i named it Prog

    5. repeat step 4, give another name for the FTP % & use this formula:
    =$H$2:INDEX($H$2:$H$16,COUNTIF($G$2:$G$16,">"""))
    it's basically the same formula but changing the column to H. i named it FTP

    6. right-click your chart & Select Data. Edit the Legend Entries. change the series values to show the sheet name, exclamation mark & your Named Range for FTP. so mine looks like this:
    =Charts!FTP
    also in screenshot inside file

    7. similarly, right-click your chart & Select Data. Edit the Horizontal Axis. change the series values to show the sheet name, exclamation mark & your Named Range for Program. so mine looks like this:
    =Charts!Prog
    also in screenshot inside file
    Attached Files Attached Files

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Registered User
    Join Date
    01-16-2013
    Location
    Oakland, CA
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Hide legend items in a graph when associated value = zero or blank

    benishiryo,

    I can't thank you enough...this is absolutely brilliant. I really can't tell you how much I appreciate your help. Your instructions were simple, easy to follow. This worked perfectly. Thank you so very much!

    - Ben

  4. #4
    Registered User
    Join Date
    10-10-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Hide legend items in a graph when associated value = zero or blank

    benishiryo,

    would this work with a spider chart as well?

    I have 4 rows (legends) and about 11 columns with information for each of these rows!

    I appreciate your help I tried doing it the way you posted it, but it isn't working for me!

    Thanks

    Ana

  5. #5
    Registered User
    Join Date
    07-07-2015
    Location
    Geneva, Switzerland
    MS-Off Ver
    2010
    Posts
    2

    Re: Hide legend items in a graph when associated value = zero or blank

    Hi, I also have a similar problem, but I need to use a line chart since I am using historical data. Unfortunately the solution above doesn't apply to my case from step 4 onwards, does anyone have an idea of how I could adapt the last 3 steps to my case?

    Thanks a lot

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Hide legend items in a graph when associated value = zero or blank

    fpunzi, welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Registered User
    Join Date
    06-02-2014
    Posts
    4

    Re: Hide legend items in a graph when associated value = zero or blank

    This. Was. Amazeballs. Thank you benishiryo!!

  8. #8
    Registered User
    Join Date
    06-02-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    1

    Smile Re: Hide legend items in a graph when associated value = zero or blank

    Thank you so much, life saver!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Remove N/A legend items
    By Platinum3x in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 03-21-2013, 06:24 AM
  2. Re-arranging items in Legend
    By ady_mech in forum Excel General
    Replies: 1
    Last Post: 04-18-2008, 04:45 PM
  3. [SOLVED] Can I remove just one title within a graph legend and not hide th.
    By KLF in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 09-07-2005, 03:05 PM
  4. Chart Legend Items: hide/show
    By Richard Ahlvin in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 09-05-2005, 11:05 AM
  5. Order of items in legend
    By Darryl in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 07-20-2005, 11:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1