January 1, 2022

Creating a Horizontal Parameter Selector with Rounded Borders in Tableau

By Luke Stanke

In this blog post, I’m going to show how to create a horizontal parameter selector. This functionality is not available “out-of-the-box”. You can select a value from a vertical list, but not from a horizontal list.

To make things a bit more complicated, I’ve been staring at the user interface on my iPhone–specifically the Photos application–and I really like the design.

For this post, I want to show you how to make this parameter menu type. Below is the example of what we will build together using Tableau’s default Superstore – Sample dataset:

Step #1: Build a visualization where you will eventually apply the parameters.

For this example we’ve built a line chart of sales by year and colored by sales region.

Step #2: Create string parameter from the field we'll use as a selector.

For this example we’ll use [Category] and create a parameter called [Category Parameter].

Step #3: Create a calculated that links the parameter to the original calculated field.

Let’s call this calculation [Category | TF]. Here is the calculation:

				
					// Category | TF 
[Category] = [Category Parameter]
				
			

Add this field to the filter of the visualization you created in Step #1. Select the TRUE value.

Step #4: Assign each category a different numerical value.

For this calculation we are going to assign each of the three different categories a different numerical value. We will start at 1.5 and count up by 3s. This will give us values of 1.5, 3.5, and 7.5. We chose 1.5 because it is halfway point to 3. 

				
					// Category Measure
IF [Category] = "Furniture"
THEN 1.5
ELSEIF [Category] = "Office Supplies"
THEN 4.5
ELSEIF [Category] = "Technology"
THEN 7.5
END
				
			

Let’s leave this as-is for now and build our next calculation.

Step #5: Build the menu coordinates.

For this part we are going to take advantage of our existing dataset. To build the menu we need only four data points: the start and end points of the background of the menu, and the start and end of the background for the selected measure. In our existing dataset we have a field called [Region] which has four members. We can use this existing field to help create our menu. Remember that [Region] is already in our visualization; this is pure coincidence, we could have chosen any dimension with at least four members. For instance, I could have chosen [Sub-Category].

For the four coordinates, we are going to set “East” and “Central” members to 0.5 and 8.5, respectively. These points will be the menu that groups all of the [Category] members together. For my “West” and “South” members, we are calculating plus/minus one unit from the selected category measure in the parameter.

				
					// Menu Coordinates
IF [Region] = "East" 
AND [Category] != [Category Parameter]
THEN 0.5
ELSEIF [Region] = "Central"
AND [Category] != [Category Parameter]
THEN 8.5
ELSEIF [Region] = "West"
AND [Category] = [Category Parameter]
THEN -1 + [Category | Measure]
ELSEIF [Region] = "South"
AND [Category] = [Category Parameter]
THEN 1 + [Category | Measure]
END
				
			

Step #6: Create the menu.

Create a new sheet. Add [Measure Coordinates] and [Category | Measure] to columns. Create a synchronized dual axis. 

For the marks card of [Menu Coordinates] choose the line mark type, add [Category |TF] to both size and color. Set the colors to be two two colors in the same family, where one is a darker shade than the other. Add [Category] to detail.

For the [Category | Measure] marks card use a text mark type. Add [Category] to text. Make sure the text is aligned middle center.

Step #7: Build the dashboard.

If you have multiple visualizations on your dashboard, make sure the menu is in proximity to the visualizations that will be affected by any action.

Step #8: Add a parameter action on the dashboard.

Setup the parameter action so that when you select a value on the parameter sheet the [Category Parameter] will update with the [Category] calculation.

Step #9: Add a filter to automatically deselect the slider after a click.

This is one of my favorite techniques for automatically deselecting text.

First, create two calculated fields: One called [TRUE] with the value of TRUE and the other calculation of [FALSE] with a value of FALSE. Add these calculations to detail the slider visualization.

Add a filter action. Select the color sheet on the dashboard. Run the action on select. Set the target dashboard to the color sheet–not the dashboard. Show all values when clearing the selection. Target filters will be [TRUE] for source and [FALSE] for target.

Final Result

Takeaways

Tableau doesn’t have rounded menus or horizontal parameter menus, but neither was too difficult to build. Using this tutorial it can be done! Just remember that you will need some extra points in your data. We used [Region] but it could have done many other ways.

Need more help making your Tableau dashboards a work of art? Our knowledgeable team of Tableau experts is here to help!

Data Coach is our premium analytics training program with one-on-one coaching from renowned experts.

Accelerate and automate your data projects with the phData Toolkit