Tableau Tooltips: Conditional Formatting

Data

Tableau Tooltips: Conditional Formatting

by Andy Cotgreave

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:

More

If they played worse, they’d see this tooltip:

Less

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.

  1. 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)
  2. 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:
    Cond format calc field
  3. Duplicate that calculated field for each Dimension value, until you have all the ones you need:
    Calc fields in dim list
  4. Now put all four of those fields onto the Level of Detail shelf:
    Level of detail
  5. 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:
    The tooltip

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!

 

More About the Author

Andy Cotgreave

Croydon Cyclone 2011 This weekend saw the Croydon Cyclone disc golf tournament. It was the biggest UK tour event for a long time, and the Croydon club ...
Panel Charts in Tableau Over on the forum, Jeremy asked about making trellis charts. For more info on trellis/panel charts, John Peltier has a great article ...

See more from this author →

Subscribe to our newsletter

  • I understand that InterWorks will use the data provided for the purpose of communication and the administration my request. InterWorks will never disclose or sell any personal data except where required to do so by law. Finally, I understand that future communications related topics and events may be sent from InterWorks, but I can opt-out at any time.
  • This field is for validation purposes and should be left unchanged.

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK