This article explains how to change the background images by using the parameter selection in Tableau.
Sometimes we need to change the background image in our dashboard/Worksheet so that we can better represent our analytical goal. As we know that, Tableau allows you to load dynamic image by using Custom maps option. Background Images are images that you display underneath your data in order to add more complex to the marks in the view.
Steps to Reproduce:
Let’s use the sample file, Sample – Superstore Sales (Excel). Open a new worksheet and select Sample – Superstore Sales (Excel) as the data source.
Once the data is loaded, perform the following steps to add a background images in the worksheet:
Step 1: (Optional)
The first requirement for using a non-map background image is to establish your own representation of X and Y coordinates i.e. we need to generate our own coordinate system. So, first open your background image (any selected image) in a tool like Microsoft Office Picture Manager or Microsoft Office to get the dimensions. Then
Microsoft Office Picture Manager View
Microsoft Office View
Add your required Dimensions/measures in the view. In my view, I am taking [Profit] in Column Shelf and [Sales] in Rows Shelf. After that I added [State] in my Color Marks and [Category] in Details Marks card which generated the below view.
For adding a background image, go to the Map → Background Images → [Data Source] and then Add Image, which resulted in a dialog box, which I filled out as shown in below image.
Select the field to map to the X-axis and Y- axis of the image and specify the left and right values as per highlighted Section of the Image mentioned in the step 2 and Click OK. In the Options tab, I made sure to select both Lock Aspect Ratio and Always Show Entire Image, because I didn’t want to either distort the image or chop off any of the sides.
Now the Worksheet will look like the below image.
Right-click in the Data window and then select Create Parameter. In the Create Parameter dialog box, do the following, and then click OK:
- Name the parameter. In the example workbook, the parameter is named BG Image Selection.
- For Data Type, select String and Allowable values as List and name the list of values.
- Right-click the parameter and then select Show Parameter Control.
Create a calculated Field by using the Parameter name .This “materializes” or “instantiates” the parameter as a field value in the data source.
Now put the newly created Calculated Field Background Selection on the Level of Detail Shelf. This makes the value of Parameter BG Image Selection available in the view.
Add another image by following the step 4, again map to the X-axis and Y- axis of the image and specify the left and right values correctly.
Go to the Options Tab, Click on “Add” Button and Select the desired Calculated Field “Background Selection” which you added in the details marks card from the List of values.
Now change the parameter value and you are able to see you background image is changing as per your parameter selection.