Charts in Excel Table Tooltips

How to display a Chart in the Tooltips on Microsoft Excel Tables visualizing the selected value within the context of the data distribution

Charts in Excel Table TooltipsThe recent post Tooltips on Microsoft Excel Tables showed a way of how to create tooltips in Microsoft Excel tables displaying additional information on the selected cell / value and some aggregated measures for the data in the active column, like sum, average, standard deviation and others.

If you are particularly interested in setting the selected value into the context of the distribution of the entire data, you may want to have a visualization in your tooltips. In other words a chart as a tooltip on a numeric data table. Sounds like turning the whole tooltip idea and concept upside down, doesn’t it? However, from time to time this can be a great alternative for adding more analytical power to your Excel tables.

Today’s post provides a short tutorial how to create a tooltip displaying a chart. As usual, including the Microsoft Excel workbook for free download.

The Idea

Tooltips on Microsoft Excel Tables - click to follow linkThe basic idea is providing additional information in Excel data tables after clicking on one cell.

The previous post described how to show a text box close to the active cell, displaying additional calculation results for the selected value and aggregations of the active data column. This is a very helpful interactive feature when you are exploring and investigating large data sets.

If have a special focus on how the selected value is related to the distribution of the entire data, you might prefer a visualization instead of raw numbers. For visualizations of data distributions, a box-whisker plot is probably the first chart type that comes to your mind. To keep the implementation as lean as possible, we will use a simplified version of the box plot, but enhanced with the selected value. The chart will show

  • the range of the data from minimum to maximum as a grey bar
  • the average as a black vertical line and
  • the actual selected value as a red cross

Charts in Excel Table Tooltips - click to enlarge

I already used a similar version of this simplified box plot in the KPI dashboard series on Chandoo’s blog (Adding Box Plots to Show Data Distribution in Dashboards).

I can’t tell you no lies: I truly like this chart type. In my humble opinion it is easy to implement, very intuitive, easy to understand and very effective. If you want to, you can call it the little brother of the band chart (see An Underrated Chart Type: The Band Chart), horizontally orientated and limited to one value.

The simplified box plot shows you where the selected data point is located in the data distribution:

  • how close is it to the minimum (or how far is it away)?
  • how close of is it to the maximum (or how far is it away)?
  • is it above or below average and how far is it from the average (the arithmetic mean, to be more precise)?

A lot of additional information at a glance. Automatically displayed after selecting a value.

However, if you prefer a real box plot or any other chart type, you can still use the technique described in this article. The simplified box plot is just one chart type example. Simply create the chart type you would like to see in the tooltips on the worksheet. The technique stays the same.

The Implementation

The implementation of a table tooltip showing a chart is pretty much along the lines of the previous post. The main difference is the fact that we are using a chart instead of a textbox. Surprisingly, using a chart in a table tooltip is easier to implement than texts and numbers.

Here are the main preparation steps on the worksheets in a nutshell:

  • Bring your data on a worksheet and assign a name to the range. Since we want the tooltip to be shown for numbers only, the range name does not cover the entire table, but only the numeric columns
  • Add another worksheet ([calculation] in our example, like we did in approach 2 of the previous post) and define 2 cells to be filled with the row and the column number of the active cell by VBA. Assign names to these two cells, too
  • Write some simple formulas to calculate the relative row and column in our defined data range based on the active row and column number and on the start cell of the data table
  • Write the necessary formulas to create the data source of your chart. For our simplified box plot we need
    • the actual value (INDEX)
    • the average (AVERAGE and INDEX)
    • the minimum (MIN and INDEX)
    • the maximum (MIAX and INDEX)
    • the value of the invisible stacked bar (MAX)
    • the negative part of the stacked bar (MAX)
    • the positive part of the stacked bar
    • and two constants serving as chart dummies
  • Create and format your chart. I will not go into the details here. There are tons of tutorials available how to create a box plot in Microsoft Excel. As usual, Jon Peltier provides a very nice how-to: Box Whisker Plots
  • Assign a name to your chart and bring it to the worksheet with the data

That’s it for the worksheets. Finally we have to adapt the VBA code we used in the previous post. In fact, we have to delete a lot of lines and change some of the remaining ones.

In one module we write a sub to simply transfer the row and the column of the active cell to the cells on worksheet [calculation] we defined in step 2 above.

In the sheet module of the worksheet containing the data table, we use the event procedure Worksheet_SelectionChange to trigger an update whenever the user selects another cell. Here are the main steps within this event sub:

  • Check if the active cell is outside of the defined table range.
  • If so, hide the chart and exit the sub
  • Otherwise update the row and column of the active cell by calling the update sub in the module (see above), position the chart to the bottom right of the active cell, assign the number format of the active cell to the tick marks of the horizontal chart axis and make the chart visible

Done.

Easy, isn’t it? 23 lines of VBA code and you are good to go. Every time you click into a numeric cell of the data table, the chart is displayed, visualizing the actual number within the distribution of the entire column.

Download

Here is the Microsoft Excel workbook for free download:

Download Chart in Excel Table ToolTips (Microsoft Excel 2003, 86.5K)

More ideas on how to improve user interactivity on your Excel dashboard tables coming soon here on Clearly and Simply.

Stay tuned.

Comments

11 responses to “Charts in Excel Table Tooltips”

  1. John Avatar
    John

    I think this is a great idea – it takes the idea of panel charts to the next level. Definitely something I intend to use in my business charting in the future
    many thanks!

  2. SteveT Avatar
    SteveT

    great post. thanks much

  3. SteveT Avatar
    SteveT

    By the way, i signed up for the emails, but didn’t get this one. I will keep 2 eyes out for the next one.

  4. Robert Avatar

    Steve,
    I just checked the feedburner email subscription list. I couldn’t find the email-address you used for your comment. I supsect something went wrong with feedburner during your subscription.
    Would you be so kind to try again and send me an email (see “EMail Me” link on the left column) after you did? I will then check if it worked this time.
    I apologize for the inconvenience.
    Thanks!

  5. SteveT Avatar
    SteveT

    tried, but can’t resubscribe “steve@…is already subscribed to the mailing list of Clearly and Simply

  6. fabrice Avatar
    fabrice

    Terrific,
    I would love to embed Sparklines in tooltips… stil have to find away !

  7. Robert Avatar

    Fabrice,
    thanks!
    Maybe I do not see the wood for the trees, but do you think this would be a big challenge?
    From my point of view you could use most of your sparklines code. All you have to do is to use a sub instead of a UDF (to be called in the Worksheet_SelectionChange sub), use some values in additional worksheet ranges instead of the UDF parameters, create and position the sparkline at the bottom right of the active cell and delete it again after a selection change.
    Or am I missing something?

  8. Frederic Gilbert Avatar

    Hello Robert,
    I often visit your site and appreciate the material and expertise you provide us with.
    I am into a dashboard project and this “chart in excel tooltips” would come handy.
    Unfortunately, I am trying to download this file (http://www.clearlyandsimply.com/files/2011/05/chart_in_table_tooltips.xls) but download never completed nor even start…
    Please, can you look into this?
    Thanks in advance for your time and effort.
    Bye!
    fred

  9. Robert Avatar

    Frederic,
    thanks for your comment and your kind words. I am glad to hear you find my articles helpful.
    With regards to your problems to download the workbook: I double checked and the link is working fine for me. Did you try to right click on the link and save it to your computer before opening? If this does not solve your problem, just drop me line and I will send the file to you by email.

  10. Frederic Gilbert Avatar

    Hi Robert,
    I wouldn't had disturbed you without first trying every way such as Save as, changing browsers (Chr, FF, IE), etc.
    By the way, I have downloaded a few others files on your site without any problem (see capture).
    Yes, please consider sending me this one by email.
    Thanks for your prompt reply.
    Bye

  11. Robert Avatar

    Frederic,
    you do not disturb me at all. I am posting the solutions for all of you and I am happy to help if you have problems with downloading the workbooks.
    However, since you posted your comment using your TypePad profile I do not have your email-address. If you send me a short email, I will reply with the workbook attached. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *