Peltier Tech Blog

Excel Chart Add-Ins | Training | Charts and Tutorials | Peltier Tech Blog

 

Main menu:

Peltier Tech Chart Utilities for Excel Peltier Tech Panel Chart Utility Peltier Tech Waterfall Chart Utility Peltier Tech Cluster-Stack Chart Utility Peltier Tech Box and Whisker Chart Utility Peltier Tech Marimekko Chart Utility Peltier Tech Dot Plot Utility Peltier Tech Cascade Chart Utility

 
Excel Dashboards
 

 
Amazon Books
 

Subscribe

Site search

Subscribe

Site search


Recent Posts

Popular Posts

Privacy and License

Privacy Policy

Creative Commons License
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

Using Worksheet Controls to Highlight Selected Data in an Excel Chart

 
by Jon Peltier
Wednesday, January 11th, 2012
Peltier Technical Services, Inc., Copyright © 2012.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

It is not difficult to build interactive charts in Excel that allow a user to selectively highlight a subset of the data for detailed examination. Excel’s semi-intuitive worksheet controls make this technique suitable for dynamic dashboard reports.

Background

Last week in Series Lines: Useful or Chart Junk?, I wrote about Excel’s “Series Lines” feature, and how it seems like a good way to clarify the data in a stacked column chart, until you implement it and realize it just adds chart junk to your chart. I proposed a panel chart to show the stacked chart data more clearly.

Gregor Aisch commented that my panel approach did not allow point-to-point comparisons as effectively as a simple line chart (despite the line chart’s clutter). So I put together the following example of an interactive chart that allows a user to compare a couple series in context of the whole data set.

Here is the original stacked column chart, with series lines cluttering up the space between columns.

Stacked Column Chart with Series Lines

Here is the panel-style chart I constructed to show the trends more clearly. As Gregor has pointed out, comparing individual point values (for example, 2008 for alpha and for epsilon) is difficult. Also, if there are many categories (alpha through omega, for example), the data will be compressed horizontally and will be impossible to read.

Original Values: Panel Chart

Our interactive chart will look like this. The user can selectively highlight data using the two listboxes next to the chart.

Interactive Chart and ListBoxes 2

Interactive Chart: Data

We’ll use this data for our exercise. A1:G7 contains the data used in the previous discussions. A9:G11 contains repeated data for two of the series in the upper table. These are selected using Excel’s INDEX() worksheet function and the index values in H10 and H11.

Data for Interactive Chart Example

Cell A10 contains the formula

=IF($H10>1,INDEX(A$1:A$6,$H10),"")

which is copied into A11. Cell B10 contains the formula

=IF($H10>1,INDEX(B$1:B$6,$H10),NA())

which is copied into C10:G10 and B11:G11. The way these formulas work is as follows:

If the index in column H is 1, column A looks blank and columns B:G contain #N/A, which is not plotted in a line or XY chart. If the index is greater than 1, the label from column A and the values from columns B:G are displayed in that row. By changing the values in H10:H11, we can change the data in their rows. If this data is plotted, then changing H10:H11 will change the chart.

Worksheet Controls

It’s nice to be able to modify a chart by changing numbers in a couple cells, but this becomes tedious after a while. Fortunately, Excel has a number of helpful controls that we can drop onto the worksheet to do this in an easier and more natural way. For choosing from among a list of items (alpha through epsilon), we can use a Combo Box or a List Box.

In Excel 2003 and earlier, you can access these controls by displaying the Forms toolbar. In Excel 2007 and later, you need to display the Developer tab*, then pick from among the Forms controls under the Insert button. (There are also ActiveX versions of these controls, and they have more extensive formatting capabilities, but ActiveX controls can misbehave.

* To show the Developer tab, you have to open Excel Options, and find the setting for the Developer tab.
In Excel 2007: Click on the big Office button in the top left of the window and select Excel Options; check the box in front of Show the Developer tab in the Ribbon.
In Excel 2010: Click on the File tab and select Options; click the Customize Ribbon button on the left, and in the right list, check the box in front of Developer.

Here is the Combo Box button on the Developer tab.

Developer Tab: Forms Combo Box Control

And here is the List Box button.

Developer Tab: Forms List Box Control

Both the Combo Box and List Box display a list of items for the user to select. I prefer the List Box, because you can several items even without clicking on the control. The Combo Box only shows one item at a time, until you click the control. Of course, if there isn’t room to display a List Box, then the Combo Box works fine.

When you click on the control button in the ribbon (or on the Forms toolbar in ancient Excel), the cursor turns into a crosshair, and you can draw your control just like drawing any other shape. In this example I’ve made two identical controls, one for each series we allow the user to highlight. You could display two list boxes side by side, two combo boxes side by side,  two combo boxes one above the other, or any other arrangement that works in the available space on the worksheet.

A few dialog arrangements

Even if I’m using multiple controls, I usually make one and format it, then make as many copies as I need, either by using Copy and Paste or by Ctrl-dragging. After copying, I change specific formats (such as the cell link, below).

When you right click on a control and choose Format Control, you are presented with this dialog. In a combo box or list box, the input range contains the list of items displayed in the control. The cell link is the cell that contains the index number of the selected list item, starting with 1 for the first item in the list. This is how the index values in H10:H11 will be changed.

Format Control Dialog

With the controls formatted and the formulas already in place, play with the controls and make sure the data changes as expected. Note that multiple controls can use the same cell link. Changing one control will change the value in the linked cell, and consequently change any other controls using this cell.

Building the Interactive Chart

The data and the controls are all set up, so now we create our charts. Select A1:G6, and insert a line chart. Resize and format the chart as appropriate.

Interactive Chart Step 1

Now format all the series to de-emphasize them. Thin lines, small markers, light gray color.

Interactive Chart Step 2

It’s easier to keep these gray series, and add duplicate series with bolder formatting for the series we want to highlight. The lighter data is hidden behind the bolder series.

To add the highlighted series, copy A9:G11, select the chart, and use Paste Special to add the data as new series, with the First Row and First Column check boxes both checked. Format these series to stand out compared to the light gray background data, and add a series name data label to the last point of each.

Interactive Chart Step 3

Now arrange the controls next to the chart. The list boxes have ugly black borders, but I hid them behind unfilled rectangles with light gray lines, and I colored the chart area border to match.

Interactive Chart and ListBoxes 1

In fact, you can relate the list boxes to the appropriate highlighted series by coloring the gray rectangles around the list boxes to match the series.

Interactive Chart and ListBoxes 2

Using the Interactive Chart

The user can now highlight and compare two series, without interference from the rest of the data which is still shown in the chart. If no other series are selected in the list boxes (or combo boxes), the corresponding data values are all #N/A, so the points don’t even appear in the chart.

Interactive Chart and ListBoxes 3

Any two series can be selected for comparison. Note how easily the opposite trends of series gamma and epsilon can be seen in this chart. In the original line chart it was very difficult to resolve these series, because the other series were not de-emphasized by shading them gray. Yet here we can still see where these two series lie compared to the overall spread of the data.

Interactive Chart and ListBoxes 4

Related Posts:

Learn how to create Excel dashboards.

Comments


Comment from Daan
Time: Wednesday, January 11, 2012, 4:20 am

Sweet!
I might keep the series name data labels for the muted versions so you have a better sense of what you are selecting (or you can better decide which category you want to select).


Comment from Calvin Graham
Time: Wednesday, January 11, 2012, 6:04 am

Good to see a controls+formula based version of doing this. You can of course do this with some quick VBA and Event macros but Excel 2007 is always trying to prevent code/macros from running and sometimes going back to this way of doing things makes more sense.

Plus it’s a great gateway for people to see charts and interactivity working together. A well made dashboard ot set of charts you can play with adds so much. The other switcheroo to add to a timeline like this I suppose is a “years or months?” breakout option.


Comment from Jon Peltier
Time: Wednesday, January 11, 2012, 8:30 am

Daan -

In cases where there are not too many series, the labels can be left in place.

Calvin -

In an ancient article I wrote about using controls to switch between units in time series. See Dynamic Charting By Dates in TechTrax online magazine.


Comment from derek
Time: Wednesday, January 11, 2012, 9:09 am

Where the number of options is intuitively ordered and small (as here, if the options really were “alpha to epsilon”, or unordered and very small (say, “England”, “France”, “Spain”) I often prefer spinners to list boxes, because they allow faster flipping between views.


Comment from Mladen
Time: Wednesday, January 11, 2012, 9:17 am

Great read and smart approach to highlighting desired data. As Daan I would also prefer to keep dimmed series names, off course, depends of overall readability.


Comment from John Broggio
Time: Wednesday, January 11, 2012, 9:19 am

Ummm – didn’t you not so long ago say that the y-axis should always start at 0?


Comment from Jon Peltier
Time: Wednesday, January 11, 2012, 1:00 pm

John -

What I’ve said is that, for a bar or column chart, the Y axis must contain zero. This is because data is encoded by the lengths of the bars. In a chart with markers, it is the position of the markers along a scale, so the requirement to start at zero is not relevant. Of course, modifying the scale affects the perceived magnitude of variation


Comment from Dave
Time: Wednesday, January 11, 2012, 1:19 pm

Sorry if this is a silly question, but how do you get the series labels to appear to the right of only the last point in the series? When I try to associate these labels, I get the name of the series next to every point in the series.


Comment from Jon Peltier
Time: Wednesday, January 11, 2012, 2:50 pm

Dave -

Before adding the label, select the series, then click again on the last point, so only that point is selected. Now add the label.

It’ll be easy now that you know how.


Comment from Jason
Time: Friday, January 13, 2012, 12:52 pm

Great article as always Jon. A minor issue I’m experiencing is with placing the unfilled box in front of the list box. It always goes behind, not in front. I tried the “Send to back” but that doesn’t work.

Are you placing the box in front to hide the black border of the listbox, or are you placing the box behind and making it a bit larger than the list box?

Excel 2007.


Comment from Jon Peltier
Time: Friday, January 13, 2012, 3:20 pm

Jason -

What do you know. I used 2010 for this tutorial, and I was actually surprised I could put the shape over the control. I had a premonition that it wouldn’t work, but it did.

Now that you mention it, I remembered that 2007 was really stupid about controls in the worksheet. All aspects of any kind of control. So I just fired up 2007 and tried this, and verified that it won’t work in 2007.

Wish I could help.


Comment from Jason
Time: Friday, January 13, 2012, 6:26 pm

Actually, if you put the rectangle behind the control and size it just a bit larger, it works out ok. I can barely see the black border of the control if I choose a darker color for the rectangle.


Comment from Jon Peltier
Time: Friday, January 13, 2012, 6:55 pm

Jason -

That just gives you a thicker dark border, doesn’t it? I guess if you’re color-coding it like I did in the last few charts, that’s fine. But if I’m not color coding, I don’t want a black border, I want something less obnoxious, so I use a light gray rectangle as in my first chart with listboxes.


Comment from Jason
Time: Saturday, January 14, 2012, 3:12 am

What I meant was if I use a darker shade of red and blue, the thin black line isn’t very visible.


Comment from Jon Peltier
Time: Sunday, January 15, 2012, 9:20 am

Jason -

I knew what you meant, I should have said it gives a thicker, dark colored border. It works to an extent, but it’s an example of something not quite right in 2007 that they’[ve corrected in 2010. Office 2007 has been likened to a beta for 2010, and Windows Vista as a beta for Windows 7. The new versions of Windows and Office are both due out within the next year, and I hope these are better than betas.


Comment from MrVines
Time: Wednesday, February 15, 2012, 4:59 pm

This is all well and good for data with like information but I have not been able to apply any of yours or Chandoo’s or a host others to my situation and I don’t think my scenario would be too uncommon. I hope with your experience that the following makes sense:

Series1 Series 2 Series3 Etc
XX 2 aaa 1 123 14 123 ?
YY 4 bbb 0 456 12 XX ?
ZZ 7 ccc 9 ccc ?
ddd 5 ??? ?

This basically says I’m collecting data say by depart (Series) and each depart has their own measuring points and # of occurances that could be the same or different than the other departments. All I want is to be able to do is select the dept in a drop down box on the Chart itself and have the data range populate accordingly. Is this too much to ask without a programatic solution (VBA)?


Comment from MrVines
Time: Wednesday, February 15, 2012, 5:03 pm

Wow that post looks horrible! Short of including the actual spreadsheet I’m working on I’m not sure how to make that mess look like I typed it up.


Comment from MrVines
Time: Wednesday, February 15, 2012, 5:12 pm

See if this works better…sorry about cluttering things up.

Series1 Series2 Series3 Etc.
XX 2 aaa 1 123 14 123 ?
YY 4 bbb 0 456 12 XX ?
ZZ 7 ccc 9 ZZ ?
ddd 5 ccc ?
??? ?


Comment from Jon Peltier
Time: Wednesday, February 15, 2012, 5:44 pm

MrVines -

Don’t worry about the formatting, I know what you mean.

What you ask can be done, but it’s rather complicated for a comment to a different post. Let me neaten up your sample data and work out a new tutorial.

Write a comment

I welcome comments from my readers. If you have an opinion on this post, if you have a question or if there is anything to add, I want to hear from you. Whether you agree or disagree, please join the discussion.

If you want to include an image in your comment, post it on your own site or on one of the many free image sharing sites, and include a link in your comment. I'll download your image and insert the necessary html to display the image inline.

Read the PTS Blog Comment Policy.





Subscribe without commenting

Peltier Tech Chart Utilities for Excel Peltier Tech Waterfall Chart Utility Peltier Tech Box and Whisker Chart Utility Peltier Tech Cluster-Stack Chart Utility Peltier Tech Panel Chart Utility Peltier Tech Marimekko Chart Utility Peltier Tech Dot Plot Utility Peltier Tech Cascade Chart Utility

Create Excel dashboards quickly with Plug-N-Play reports.