## Heatmap Tables with Excel – Revisited

We’ve revisited one of our more popular guides Heatmap Tables with Excel as they can be a very effective way of presenting data on a dashboard, and have now updated it for Excel 2010…

This Heatmap Table is designed to show you the revenues and the discounts of a company over the course of one year per product group. The size of a bubble shows the revenue made in a particular month and the bubble color shows the discount rate given. The discount rate has been encoded as a range of green colors, ranging from a light green, for low discounts to a dark green for high discounts. The years and product totals are shown at the right and bottom as an integrated part of the table.

Tufte often talks about the integration of numbers, images and words; I think he’s quite right. A way to achieve this in Excel is to integrate charts into tables, so called graphical tables, a very effective means to show “More Information Per Pixel“.

The heatmap table is based on a regular Excel bubble chart. To integrate a bubble chart into a table the bubbles are positioned in a matrix that has the same row and column layout as our table.

In our case we generate a data series table with one column for the X-Series going from 1-12 for January – December and one column for our Y-Series going from 1-8 for our 8 product groups and one column for revenue.

In the sample spreadsheet we’ve setup some simple excel formula to translate data from the classic grid layout:

to the required format:

Now we can insert the bubble chart:

To ensure that the charts fit exactly into the table grid we set Min/Max for the X axis to 0.5/12.5 and for the Y axis to 0.5/8.5. Excel would calculate much larger auto scales otherwise. Also set the Major units to 1 so we can use that later to set some grid lines.

Now we remove the legend, the X and Y axis, maximize the plot area and align the chart with the Excel table. As the bubbles are initially too large we have to make them smaller. To control the bubble size go to Data Series Options and scale the bubble size to 50%:

This already makes a nice bubble table you could use to reproduce the Twitter Charts.

For the grid lines format your table headers and grid lines with light gray grid lines. Resize the plot area, remove the border and re-position the chart so that the chart and the table grid lines align.

To create the heatmap with different colored bubbles we use the fact that by default Excel does not plot data points for #NA values.  For the heatmap we overlay 8 bubble series, one  series per green shade, and show a revenue bubble only if the value fits into the value range that corresponds with a green shade of our color ramp, otherwise we show #NA.

We divide the range MAX(Discount)..0 into 8 groups to define the colours.

The data series columns use the following formula to test if a discount value corresponds with an interval / colour shade:

=IF(AND(\$E7>I\$6-Step,\$E7<=I\$6),\$D7,NA())

The formula returns the revenue, if the discount values is in the interval defined in the column header I\$5.

Now create the eight data series so that the bubble size refers to the eight columns in the data table:

And use the Excel chart styles to pick a colour range – make sure you  remove the border from the chart area.

And you could use the chart styles to quickly switch between different colours – or customise each series to refine the colors.

You can download a starting point for these files here: HeatmapSample.xlsx. Most of the formulae should adapt to data values that you can feed into the data sheets, including data straight from Analysis Services if using XLCubed grids or formulae.

You can see an interactive version of the Heatmap here – we added a link to some cube data, some Slicers for driving the parameters and then published to XLCubedWeb.

/

## In-Cell Variance Charts

In financial report we are constantly comparing the actual numbers with our projections using variances.

A quick reminder

Absolute variance = Actual – Budget

Relative variance in % = (Actual – Budget) / Budget

Doing this over a report of even 10 lines requires row by row number comparison, and is not something which can be easily & quickly scanned. Showing the variances in a classical Excel charts is problematic, as you constantly have to go back and forth between the table and the chart to scan exact numbers and the variance tend in the chart.

In-Cell variance charts are a compact, data rich and efficient alternative.

To create in-cell variance charts you have basically three alternatives:

1. In-Cell Chart Using the REPT Function

Rolf Hichert presents a couple of years ago on his web site (German) a character based approach. The method got quite popular when it was first presented on the  Juice Blog. The main idea is to create the bars repeating a character using the REPT function. The function REPT(“●”,5) returns “●●●●●”. The disadvantage of this approach is that you have to set up all the formulas and that don’t have a continuous scale. E.g. to show 15% you either show “●” or “●●”, but there is no way creating fractions of a character. One of the advantages of the rept approach is that the bars are automatically aligned in the grid. When you increase the row height, bars are still perfectly aligned with the numbers.

2. In-Cell Chart Using MicroCharts

Another smart way to overcome the setup and scale problems of REPT is using MicroCharts. Charts are created from MicroCharts fonts including bars, line segments and pies. A chart is represented as text that is formatted with the MicroCharts fonts. Similar to the rept fuction charts, you can utilize all the rich Excel capabilities for MicroCharts that you would for normal text!:

• Text alignment
• Text orientation
• Font size
• Conditional formatting
• Automatic alignment when the row height changes

Unlike the rept function MicroCharts support continues scales value axis. The chart formatting is very similar to the options with standard Excel charts:

Hitesh Patel Winner of 2008 Excel Dashboard Competition used the Micro Bar Charts to visualize variances over areas and territories in a very cleanly presented table in his Pharmaceutical Sales Dashboard .

3. In-Cell Charts Aligning a regular Excel Chart in the Grid

A third approach is to use regular Excel bar charts:

The trick is to set chart area to transparent and to manually align them to the grid. The main problem with this method is that the setup of the chart can be very tedious. You will have to fiddle quite a while till the bars align perfrectly with the grid, and each time you change the row or column height width you have to readjust the chart area:

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:””;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:”Times New Roman”;
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}

Update 06/28/2008: Jon added some insights how to handle variable rows and fourth approach for incell charts using graphical objects:

One problem arises when the number of rows covered by the chart is variable. When you have an update, you need to rely on VBA code to realign the chart, and this is not always reliable. To counter this (and to apply some “interesting” formatting requested by the client, I developed some VBA code that read values from each row and built chart using a series of rectangles and other shapes. These were aligned appropriately with the grid more simply and reliably than a chart would have been. A sample of this is shown in In Cell Charting with Shapes.

I ran into additional issues with another client who insisted that his worksheets be viewed at a zoom that filled the entire width of the screen. This has all kinds of negative issues, especially with charts. (And on my widescreen laptop, it needed a zoom of around 150%, so I had minimal rows visible. But a client is a client.) So I built some additional graphs based on Excel shapes, as illustrated in In Cell Bar Charts.

You could therefore add a fourth approach, though it isn’t accessible without code, and that is “Graphs using Graphical Objects”. This is after all how we all started with graphing data in second grade, with paper and crayons and perhaps a straightedge.

Extra tip: To further enrich your variance report with some historical context, provide the historical performance in an extra column as a sparkline:

/

## Graphical Tables – An Alternative to Treemaps

Sean blogged the other day about using a treemap to visualize the drivers of the Australian Inflation. He got inspired to create a treemap by an NYT article that used an interactive version of the following treemap:

This chart looks nice on the first view. It makes nice use of muted colors, the shapes look well balanced and certainly the graphic designer did a good job. However, from a data visualization perspective this chart has a couple of flaws.

Ben Shneiderman designed Treemaps to visualize deep directory tree structures.

Ben explained treemaps in an article as:

“Among the growing family of visual analytic tools, treemap are flourishing in organizations that require daily monitoring of complex activities with thousands of products, projects, or salespeople. Tabular reports, bar charts, line graphs, and scattergrams are important tools, but for complex activities where there are numerous sales regions, manufacturing plants, or product lines the hierarchical structures provided by treemaps can be helpful. While tabular displays and spreadsheets can show 30-60 rows at a time on typical displays, the colorful presentations in treemaps can accommodate hundreds or thousands of items in a meaningfully organized display that allows patterns and exceptions to be spotted in seconds.[…] Treemaps are a space-filling approach to showing hierarchies in which the rectangular screen space is divided into regions, and then each region is divided again for each level in the hierarchy.”

The first problem the NYT chart has is that it does not visualize the hierarchy as rectangular areas. The inflation drivers are visualized as asymmetric round shapes. It is difficult to compare the relative size of rectangular shapes but it gets almost impossible for asymmetric shapes. Also does this treemap lack labels for the smaller inflation drivers.

Sean published in his blog post a treemap which does not have the problems mentioned above:

Ben designed treemaps to visualize thousands of regions, products, etc ; but the Inflation chart only comprises 20 Inflation Drivers grouped into 7 categories. A simple sorted table would do a better job communicating the numbers as Kaiser Fung from Junk Junks wrote in his post.

Inspired by this post and my comment Sean came up with this graphical sparkline table designed with Excel and MicroCharts.

This is already quite an improvement on the treemap, as we can see increasing and decreasing inflation trends and sparklines rather than traffic light colors as in the tree map version. Also it is much easier to read for non expert users.

Some minor things we can improve in Sean’s chart are:

• We can sort the inflation drivers by Weight, to have the most important ones at the top
• Changing the area to the sparkline puts emphasis on the trend rather than the absolute value of the values (as the area chart does)
• Inline deviation charts allow us to visualize the MoM and YoY % changes

/