You may have noticed that our blog doesn’t allow you to make comments. We can assure you that this is not because we don’t value conversation! It’s simply taking us time to implement all the features we want on the blog. Much as we’d love to be blogging full-time, clients have pressing demands and we haven’t been able to implement the comments section yet.
The XX won the Mercury Prize last night. It’s a great album. I personally would have preferred Wild Beasts or the Villagers, but they were a little “out there” for a thinly-veiled sales generator. You can see my Mercury Prize Tableau viz below (or click here for a full screen version). I also created a Spotify playlist of all the artists (well, the ones who are on Spotify!). You can get that playlist here.
This is the second post about tooltips. In this post, I will describe a technique to add conditional formatting, of a sort, to your viz. This isn’t a natively supported feature in Tableau (although it would be lovely if it was!), so you have to do a bit of extra work to do it.
I’ve implemented colour-based conditional formatting in a few Tableau Public dashboards. My disc golf analysis dashboards use colour to emphasise the good/bad performance of players. Click here to go to the viz; the tooltips are below.
If the player played better than their rating, they’d get this tooltip:
If they played worse, they’d see this tooltip:
I’ve also used colour to represent a political party’s colour, as shown in my UK General Election viz. The main dashboard is here, but I’ve embedded one of the worksheets below. Hover over the different parties (Labour, Conservative, etc) to see the different colours in the tooltips:
There are a few limitations to using colour. Essentially, this boils down to having a Dimension or Group where the possible values are known ahead of time and are relatively small. Why’s this? Because to take advantage of conditional tooltips, you need to create a specific calculated field for each Dimension value.
Here’s the steps to create the coloured Party tooltip in the General Election dashboard.
- Determine the list of items that will need their own colour. For our general election, there are four. One for each of the three main parties: Labour, Conservative and Liberal Democrats, and one for everyone else (Other)
- We need one calculated field for each of the four values. It is a basic IIF function that either returns the Dimension value as a string, or an empty string (note – it must be an empty string, not Null).
In my dataset, the underlying party column was a single letter, so the calculated field for Conservatives was this:
- Duplicate that calculated field for each Dimension value, until you have all the ones you need:
- Now put all four of those fields onto the Level of Detail shelf:
- The final step is to edit the tooltip. This is quite straightforward, but looks a bit messy. Order the calculated fields so that they are all adjacent in the tooltip text. Format each calculated field with the colour that you want. For the election tooltip, this looks like:
That’s it! All but one of the calculated fields will be Null at any one time (since you can’t hover your mouse over more than one mark at a time). Therefore, despite there being four items in the tooltip, the viewer only ever sees one. And it just happens to be in the correct colour. Bingo!
Tooltips are the missing link between a mark and its underlying data. They provide a valuable opportunity to explain more about the chart without requiring the user to examine the underlying data.
The motivation for these posts was seeing so many vizzes on great charts on Tableau Public being let down by the publisher leaving the tooltips in their default state. It’s easy to think this okay, but the tooltip is an eager beaver: even viewers with hyperactive mouse movements are guaranteed to hover long enough for the tooltip to appear. Given that’s the case, you want to make sure you’re showing the user something pretty!
I’ll start off with basic good practise tips; later posts will look at advanced techniques to make your tooltips shine.
1 Make a header
My first rule when publishing a viz, is to put a “Header” into the Tooltip. The header should be the mark’s primary dimension, or a summary. For example, consider the default tooltip on the Sales Outliers sheet in the Wow Workbook:
I can’t deny that the tooltip has all the info and, yes, the tooltip is an elaboration of the mark. But it doesn’t really draw the eye, or encourage fast interpretation. Now let’s see what the Tableau staff actually did to the tooltip when they released the workbook:
See what they did? They moved the two main dimensions,
2. Less is more
When building your viz, some of the dimensions/measures you add to the worksheet might be necessary for the viz itself, but have no meaning for the viewer. For example, here’s the default tooltip from my visualisation of Pub Closures in the UK:
As you can see, the are two dates, yr and Year. One is a year, and the other is a date. The latter is necessary in the viz to use a continuous scale on the x-axis, but meaningless for the viewer; all they care about is the year. Delete the unnecessary data from the tooltip.
3. Make sure the labels are meaningful
If you’re using aggregations or table calculations in your view, the default label might be something crazy like “% of Total Count of Rate:” This isn’t always too intuitive. Look again at the default tooltip from the Pub Closures viz (above).
“Difference in Min. year_number”? What? Well, it’s a nice description of the table calculation, but it’s a terrible description of the information. In this viz, it really represents “Years since party came into power”. By making all the labels meaningful, you can end up with this:
4. Order! Order!
Make sure the most important information is at the top of the list, if that’s relevant. Continuing the work on our pub closures tooltip, we should improve the tooltip like this:
5. A sentence can say more than a label
If the tooltip has quite a lot of information in it, it can be better to turn the fields into a complete sentence that fully explains the mark. A long list of labels, colons and values can be confusing. Here’s how the final tooltip for the Pub Closures viz looked:
That’s it for this first post. Next time, we’ll look at a couple of advanced tooltip tips.
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:
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:
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…
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:
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.
I like disc golf. It’s the same kind of thing as ball golf, but played with discs (“frisbees”). Instead of holes in the ground, discs are thrown to metal targets. Just like ball golf, there’s a plethora of stats generated. This weekend saw the Scandinavian Open take place in Sweden. This is one of the biggest events in the calendar, and draws the top players from around Europe and the USA. The guys put the scores up promptly, so I thought I’d take their data, and visualise the results.
I created two dashboards using their results:
The Player dashboard
The Hole by hole dashboard
Here in the UK we have just been through (and, at the time of writing, are still enduring) a general election. This presents us with some fantastic datasets. The first place I turn to is the Guardian Data Store, and they provided this, which allowed me to create Election results dashboard below.
I won’t comment much on it, but it does utilise three tricks that I hope to explore and explain in the coming weeks:
- Hyperlinks on sheets
- Conditional formatting on tooltips
- Positioning the text label in the bars
Enjoy the viz, and please post and comments below.
Those who know me from the Tableau forums or Twitter, or the UK Tableau User Group know that I love Tableau.Those that don’t know me: well, I work at the University of Oxford, and have been using Tableau since December 2007. Since then, I have been raving about it, Ancient Mariner style, to anyone who catches my eye.
It’s been inevitable that I’d set up a blog. What do I hope to add the world of Tableau knowledge?
- A repository for hints-and-tips on Tableau
There aren’t many people blogging about basic/advanced Tableau jedi tips. The inspiration for this approach is from blogs such as Daily Dose of Excel – a great place to learn things.
- A showcase for mine and others’ Tableau Public visualisation
There are several other great blogs doing this, and I hope this blog adds to the general commentary
- Occasional discussions of other info viz related matters
I hope to help everyone advance their Tableau knowledge. Along the way, we’ll learn some things that are useful on a day-to-day basis, and some things that you may never need, but could inspire you to think differently about things.
Let me know what you want to see me cover. Are there any beginner/jedi tips not covered in Tableau’s excellent Learning Centre?