During a client project week in The Data School, I had this task of creating dynamic tooltips on a cross table in Tableau. By saying dynamic tooltips, I mean three goals to achieve for this project.

  1. Tooltips only show for a specific column in the cross table.
  2. Apart from text, there is a viz in tooltip as well. The viz in tooltip will be filtered by the row category.
  3. The cross table has a grand total at the bottom, the viz in tooltip will show all data when shown for the grand total.

After the client project, I have replicated this dynamic tooltips based on the Sample Superstore dataset. You can see the meaning of these dynamic effects from the video clip below.

 

To achieve this, following techniques are used:

  1. Parameter and parameter action.
  2. Set and set action
  3. Calculated field

When searching for help to build this, I found out that only separate parts could be found. So by piecing them together into this example, I hope you will find this useful. Next I’ll talk about how to implement this in Tableau in detail.

  • Identify a specific column by parameter and parameter action

When buidling a cross table in Tableau, make sure “Measure Names” is on Columns shelf. In this example, three measure values are shown as different columns. Only Sales column will show tooltips. So first we need a way to indentify that the mouse is hovering over which column. To do this, we need to create a parameter first. Name it “Measure Name” and set Data type as String.

Then we can set up a parameter action to dynamically set the value of this parameter.

The Source Field is set to “Measure Names”. Then when hovering over different columns, the value of the parameter will be set to the measure name accordingly. Eg. when hovering over “Sales” column, the parameter will be set to string “Sales”.

  • Create calculated field to show dynamic tooltips

The next step will be creating the calculated fields for the content of the tooltip. In the calculated field we can use the condition to only set contents for the specific column/s. The contents for otther column/s will be empty hence no tooltips for those column/s.

First we show text of Sales value by creating a calculated field below.

Then we drag this calculated field into tooltip. We can see that only when we hover over the “Sales” column the tooltip will be shown.

Next we create another calculated field and copy and paste the whole link of the viz in tooltip into this field.

After adding it into the tooltip, we can see that the viz in tooltip will be shown for the “Sales” column only as well. But the problem is the filter will not work for the viz in tooltip any more, even though the filter = “<All Fields>” is still there. So we need the help of a Set and a Set action to work around this.

  • Create Set and Set action to apply filter to the viz in tooltip

The first dimension in rows is Category, we’d like the viz in tooltip be filtered by Category. But for the row of the grand total, we’d like the viz in tooltip to show all Categories. First we create a set on Category using the default setting.

Then add this Set as a filter on the viz in tooltip worksheet and create a Set Action to set the value in Set.

By now you can see the dynamic text and viz in tooltip when hover over the “Sales” column only. The beauty of this set action is that when hover over the grand total row, the viz in tooltip will show all Categories automatically.

Another small tip here is that if you want to add a title for the viz in tooltip to show which Category it is showing, you can create a calculated field to do this. The trick here is that if the tooltip is from the grand total row, you should be able to know it and show “All” as category. To do this, use the calculation below.

 

Thank you for reading this blog. Hope you find it useful to you.

The Data School
Author: The Data School