Tableau Tutorial - Dealing With Exceptions in Tooltip Text

I ran into an issue while making my dashboard for the first round of applications to the Data School. I had a line chart with the number of bike crashes by year. In the tooltip, I added in the percent change in number of crashes from the previous year. However there was an issue with 2010, the first year in the dataset. Without data from 2009, the percent change from 2009 to 2010 can't be calculated. I wanted to have my tooltip text in the following format:

But in 2010, the tooltip looked like this:

After a lot of Googling, I finally found a solution. Using a calculated field, you can create tooltip text that is present when you want it to be and absent when you don't want it to be. I created the calculated field below:

This field will have an empty string (the two single quotes with nothing between) for 2010 and the text 'change from previous year' for all other years. Once that's done, all you have to do is drag the calculated field to the tooltip shelf. Then click on the tooltip shelf, click Insert, and click on the calculated field from the dropdown menu (I called my calculated field Tooltip Text so it appears as ATTR(Tooltip Text).

Once you do this, the calculated field will appear in your tooltip and you can move it wherever you want it to be. You can use this for other things, like creating exceptions for singular nouns.

Author:
Daniel Bostrom
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab