Tableau

Show pictures in your Tableau tooltip

Since the release of Tableau version 10.5 we have been able to use visualizations from other sheets in the tooltips. One of my favorite applications of this feature, is that it allows me to enhance my data with pictures in the tooltips.

Do you want to show an image of the specific product sold when hovering over a bar-chart? Do you want to be able to identify an employee directly from the dashboard? Or do you want to give the user a preview of a location on your map? Pictures in the tooltip is the answer to these questions.

In the workbook below, I have created an overview of bathing places to visit during the Summer in Copenhagen. The workbook gives the user the possibility to see a picture of each of the bathing houses, so they can choose the place that fits their preferences.
Each picture is represented by a background image on eight different sheets.

This blog post will take you through the steps of using background images to get pictures in the tooltips.

Step 1 – Create an Additional “Coordinates” file

1.1 To use a background image, you first need to create an excel file with each dimension you want to visualize, in this example the bathing houses, and assign a X- and Y-number to each of these to be used as the axis.

Step 2 – Add the Excel file to your Tableau workbook

2.1 On the Data Source pane in your Tableau workbook add the new Excel file with the dimensions and coordinates to the workbook:

Step 3 – Add the relevant pictures as Background Images

3.1 Go to a new sheet.

3.2 Click on the “Map” tap at the top of Tableau. In the drop down menu choose “Background Images” and the data source you just created with the coordinates:

3.3 In the menu that appears click “Add Image”.

3.4 A new menu will appear, here you should “Browse…” to the image you want to add.

3.5 Afterwards it is important that you specify the “X Field” and “Y Field”. Which in this example is simply the columns I have named X and Y in my coordinates file.

3.6 Next you need to specify the ranges for the X- and Y-axis, with the coordinates I have put in it works well with the following:

Left=0 and Right=1000

Bottom=0 and Top=1000

3.7 Click “OK” and add additional images in the same manner.

3.8 When all images are added you should deselect all images for now and move on to the next step.:

Step 4 – Show the Background picture on the sheet

4.1 On a clear sheet, use the coordinates datasource to filter on one of the dimensions you want to picture; in this example: Amager Strandpark.

4.2 Name the sheet the same as the dimension you filtered on, in this example: “Amager Strandpark”.

4.3 Drag the “X” measure to Columns and the “Y” measure to rows.

4.4 Now go back to the “Map” menu in the top of Tableau, navigate to Background Images and the Coordinates file, and get back the Background Images menu. Select the relevant picture:

The picture should now appear on the sheet.

If the axis does not fit, go to the Background Image menu and double click on the relevant picture, here you should change the ranges of the axis so they fit the picture.

4.5 To get rid of the axis right click on both the X- and Y- axis to deselect “Show Header”:

Go through step 4 with all your different pictures, so that you have a sheet for each picture. In this example I have a sheet for each bathing house showed on the map.

Step 5 – Add the picture to the tooltip

5.1 Create the sheet where you want the pictures to appear in the tooltips.

The standard coding for adding a sheet in the tooltip looks as follows:

<Sheet name=Amager Strandpark maxwidth="300" maxheight="300" filter="\<All Fields>">

But we want the image in the tooltip to be dynamic, so depending on which data point we are looking at, the tooltip should refer to a specific sheet. Therefore, we need to create a calculated field we can use in the tooltip.

5.2 Create a new calculated field, where you use the formula CASE to refer to the Dimension you have pictures off, in this example the Dimension is called “Bathing Place”.

I write a statement for every Bathing place and the sheet I want it to refer to, which I named the same as the Bathing place, hence it looks like the following:

Where “maxwidth="300" maxheight="300" filter="\"> is held fixed and refers to the size of the sheet in the tooltip. Thus the only thing that changes is the name of the sheet.

5.3 Drag the new calculation “Picture in Tooltip” to Tooltip on the Marks menu.

5.4 Click on tooltip in the Marks menu. In the tooltip menu, insert a random sheet to get the correct syntax:

5.5 As you have added most of the syntax in the calculated field you can delete everything after the equals sign and replace it by the calculated field you just created:

5.6 Click ok and hover over any of your data points to see the magic!

Bonus: I found the longitude and latitudes for the bathing houses in the Municipality of Copenhagen on //data.kk.dk/dataset/, which is a webpage that gives you access a lot of free data about the municipality.


Back to blog


Subscribe for updates