Joy of six: dynamic multi-member groups

First off, let me say that I do not take credit for the contents of this post. Credit is due to Joe Mako and Richard Leeke who responded to my questions on the Tableau Forum. This is a good time to say that if you aren’t using the forum yet, get over there to ask or answer all manner of Tableau questions from the trivial to the fiendish.

I am posting this solution because it is such a sweet use of calculated fields. Here’s the scenario: “I want the user to be able to see the top n customers’ average sales. They should be able to control the “n” value, and show or hide all the rest of the customers.” Here’s the answer:

I’m afraid I am not going to go through the solution. Why? Well, I barely understand it myself, and I don’t think I’d be able to explain it properly. I recommend you download the workbook and look at the forum thread to work it out. Otherwise, just be in awe at the work of Joe and Richard!

How to make bubble charts

Flowing data posted nice and clear instructions on how to make bubble charts using R. It’s a great post, and I thought it would be a good thing to show how to create the same chart in Tableau. Readers can compare and contrast the ease of each. Let me know your thoughts in the comments below. Here’s the end result using Tableau:

To create this:

Step 0: Download Tableau Public

This example uses Tableau, so you’ll need that.

Step 1: Download the data file

It’s here: http://datasets.flowingdata.com/crimeRatesByState2008.csv

Step 2: Connect Tableau to the data

Step 3: Build your bubble chart

You only need five Dimensions/Measures on the worksheet to make the view look the same as the one on Flowing Data. I added Colour to State in order to create the highlighting option in the dashboard above. Is this cheating – it’s 6 drag and drops – is that 6 separate steps? 🙂

Step 4: Clean up!

I prettified it a bit by changing the Mark borders and putting it into a well-proportioned dashboard.

The whole process took me 15 minutes. Once your up to speed with Tableau, you can get to work at lightning speeds.

Flowing Data’s post started off by mentioning Hans Rosling and the Gapminder project. Watch this space for more on Gapminder and Tableau….


The joy of six: add an “About” box

You may have seen my response to an Information is Beautiful post. Here’s the viz I used in that post:

This uses sheet tabs to create an “About this viz” tab. It is good practise to credit data sources and date your vizualisation. The About Box allows you to do this. I’ve used parameters to store the hyperlinks, and dropped them onto worksheets embedded into the “About this viz” dashboard.

Prior to v6, the choice was either to omit the credits, or squeeze them into your dashboard somehwere. No more!

The joy of six: user-built views

Today is the Joy of Six day. Tableau v6 is incredible, and I’ve been lucky to have had my hands on the beta versions for a while. The Tableau site itself is a great resource for learning about the amazing new features and how to use them. I wanted to do a series of posts about how these new features are already being practically applied to solve our own real world problems.

A common problem we see is that we build a view for a user, only to have them say, “Hey, that’s great, but instead of Profit, can you show Sales? Oh, and also, I’d like to see it broken down by Container, not State”. In the old days (pre v6) you had to build a view for each request. Not now. Oh no. Not now. Now you can build in masses more flexibility into your views.

The dashboard below shows an example using Tableau’s sample data:

How do we do this trick? First let’s look at the pills that build this view.

Instead of using the actual dimensions or measures, each pill is either a parameter, eg “Choose columns”, or a calculated field based on a parameter, eg “Chosen column dim”.

There are four parameters in this view (for more on Parameters, check out this video on Tableau’s own site):

Each of these is a String List, looking something like this:

Each item in the List of values box should be a Dimension (in the above image) or a Measure (not shown) you want to the user to be able to choose. You need a parameter for each user-editable area of the worksheet.  In my example, that’s a parameter for Row, Colum, Bar length, and Colour.

Once you have your parameters, show them all on the worksheet (right-click on the Parameter name and choose Show parameter control).

Our next step is to connect some calculated fields to each parameter. The “Bar” calculated field looks like this:


The IF statement returns a different Measure, depending on the value of the Parameter.  There are four calculated fields – one for each parameter. I created the following for the viz above:

  • Chosen row dim
  • Chosen column dim
  • Bar
  • Colour

Now you can build your view – drop the calculated fields onto the relevant shelf, and you should now have a dynamic view where the user gets to choose what they want to see.

The final thing you should do is format the tooltips, as the default ones will make no sense. See my previous posts on tooltips for some tips.

Download the workbook to explore how it’s done in more detail.

London 2012 ticket prices

London 2012 published the Olympic ticket prices today. There’s lots of good value seats to be had. I took the data from the London 2012 site and built this viz that you can use to find out how much your favourite sport will cost you:

Note: this viz does not include the Opening or Closing ceremonies. Top price seats for those will set you back a max of £2,012 and £1,500 respectively! Ouch

Telecoms companies: who’s suing who?

There’s a chart doing the rounds that shows who is suing whom in the telecoms industries (eg at the Guardian). David McCandelish has improved it nicely here, and asked the question of whether companies who’s revenue is going down are more litigious than those on the rise. Well, I took his data from here and created the charts below.

There are lots of caveats: I excluded Smartphone Technologiess LLC because the data didn’t say if their revenue was up or down. That’s a shame, because they’ve got the most lawsuits open. Also, we don’t know if the revenue was going up or down when the lawsuit was started.

PS – for Tableau geeks, the tooltips on the chart are using my Conditional Formatting trick (click here) to make the text colour change depending upon Revenue Direction.

Text-labelled bars: beyond the default

By default, Tableau won’t label a bar. The axis is enough for viewers. However, a lot of our users say to us, “We like the bar, but we want to see the numbers as well“. Rather than reproduce a bar chart as a table, labelling the bars is the obvious way to go. Tableau provides an obvious way to do this, but this viz below shows 3 other ways you can label the bars.

Example one in the above viz is the default – just copy the Measure that’s on the Columns shelf to the Text shelf of the Marks card:

Default text

In Example two, I’ve added Color to the Marks shelf to get a stacked bar chart. By default, the Text marks would now appear in each segment. If you still want the total label visible, you need to add a Reference Line. Right-click on the axis and choose Add Reference Line…

You then need to add a Line with the following settings:

Totals Reference Line

That’s cool – you’ve done some labelling that is outside of Tableau’s default behaviour. What if you want to add some allowable bling to your chart, ie do something visually attractive, but stick to the principles of good visualisation? Well, you can put the text label inside the bar.

The third example, with the white text inside the right-hand edge of the bar, is also acheived with a Reference Line. To do this, create a reference line with the same settings as the previous example.  Now select the Reference Line and choose Format…

Format Reference Line

On the Format panel, set the Reference Line Label Alignment to Left-Align (horizontal) and centrally aligned (vertical). Change the Shading to 0% and the Font to white. Bingo! Your text is now inside the right-hand edge of the bar.

The fourth example, aligning the text at the left-hand edge of the bar, next to the category label, was something of a quest for me after seeing that it can be done relatively simply in Excel. To achieve this, we need to twist some of Tableau’s other functionality to suit our needs!

The first step is to remove the Measure mark from the Columns shelf, and put it onto the Text shelf. Yes, that means we have just created a table, not a chart. Stick with me, we’ll get there. Now put a copy of the same Measure onto the Size shelf. Still looking a bit wacky? Ok, the final step is to change the Mark type from Automatic to Bar:

Left-aligned text in a bar

You should now have your left-aligned labelled bar.

The techniques for examples 3 and 4 can enhance your Tableau charts. There are some restrictions to these two though:

  • They only work on horizontal bars
  • If one value is very low, the label may not appear correctly
  • For the left-aligned text (example 4), it works best with a big range of values.

You may also have noticed that I have hidden the axes on all of the charts above. I believe that if you are going to put text-labels on the bars, it’s bad practice to also show an axis.

To get a better idea of how to do this, download the workbook to see how I built it all up.