Tableau Menu Bar Charts

Discover how to make Tableau Menu Bar Charts

Tableau Dashboards can be made more interactive by adding buttons. While there are a few options to achieve this, an elegant way is to use a Bar Chart in combination with Dashboard Actions. In this blog we will examine how to make what can be called Menu Bar Charts in Tableau.

A Bar Chart as a Menu

Let’s take a look at an example first. A while ago I made a dashboard about the inhabited islands of the Netherlands. Take a look at my Tableau Public page if you are interested. I wanted users to be able to pick a category of islands (so they could then pick an island from a small list).

Unlike the original version of that dashboard above, the screencast below shows a Menu Bar Chart with all the islands immediately ready to be picked.

We see that when you click on one of the buttons to the right, the map on the left updates to show that particular island. This is menu bar functionality in its most basic form. In the following paragraphs we will take a look at how to create such a menu bar.

Steps to create a Menu Bar Chart

In order to create a Menu Bar Chart in Tableau we need to follow a few steps. First we need to create a new Worksheet with the Bar Chart that we are going to use. Then we need to add that Worksheet to the Dashboard. When we have the structure of our dashboard in place, we can add a few Dashboard Actions. The most important dashboard actions that is necessary is a Change Parameter Action (Change Parameter…). Selecting the name of an island in the Menu Bar Chart needs to set a Parameter, so that the map (to the left) can be filtered by this Parameter (and therefore show just the island we want to see). Lastly, we want to add a Filter Action (Filter…) that prevents a selection on the Menu Bar Chart from greying out the names of the other, unselected islands.

  1. Create the necessary Parameter
  2. Create a Menu Bar Chart Worksheet
  3. Add the Menu Bar Chart Worksheet to the dashboard
  4. Set up a Change Parameter Action
  5. Add a Filter Action

Creating a Parameter

First of all we need to make a new Parameter for the dashboard interactivity to work. Start by right-clicking the side pane to the left, selecting Create Parameter…, and assigning a relevant name. Then you should choose String as the Data Type. Set the Allowable values radio button to List and click on the When workbook opens radio button (thereby deselecting Fixed). Then select the Field you want to use from the drop-down just below. In our case it is [Name Island]. Finally, click on OK to close the Dialog Box.

Creating a Menu Bar Chart Worksheet

The second step is to make the actual bar chart. We do this by adding a new Worksheet and setting the Mark Type to Bar. Then we want to drag the Items that we want to appear in the menu to the Label Property on the Marks Card. In this case that Field is named [Name Island], but you can replace it with any dimension (with the strings you need).

Since we want the Bar Chart to fill the entire container on the dashboard there are few things we need to setup. First of all, we want the Names to appear vertically in this case, so we need to have a Measure on rows. This could just be “SUM(1)”, but in order to make our Bar Chart more flexible we will write a LOD-expression straight on the Rows Shelf by double-clicking on an empty spot on the Rows Shelf. Then we enter:

{ SUM(1) / COUNT([Name Island]) }

This will make sure that the bar chart is always of length 1, irrespective of how many island names there are in de dataset. Please note that both SUM(1) and COUNT([Name Island]) are both aggregates and this is also necessary.

Giving the bar a better look

Now the bar chart already shows us what we want, but it is not pretty. First, let’s edit the axis so it has a fixed range from 0 to 1 (so we did not use the LOD-expression for nothing): right-click the Vertical Axis, click the Fixed radio button and set the Fixed start to 0 and the Fixed end to 1. Then remove the Axis by right-clicking the Field on the Rows Shelf we just made and deselecting Show Header. Also, the size of the Marks should be set to full: click on the Size Property on the Marks Card and drag the slider all the way to the right.

Subsequently drag the right side of the bar chart to the right so it becomes bigger. Edit the Label Property if you want and more importantly: don’t forget to select the Allow labels to overlap other marks checkbox. Otherwise the labels might not show.

Add color

At this point it is time to add some color! We created a Parameter in order to do this. Double click an empty space on the Marks Card so we can enter and Ad Hoc calculation. In order to test whether the selected value is the same as the Parameter, you need to enter an Equals expression. In our case that would look like this:

[Name Island] = [PAR island]

We can change the Mark Property from Detail to Color afterwards. Be sure to to set the Border to something else than None. Choose White for example. This can be done by clicking on the Color Property. Do make sure to have the Color Field after the Text Label Field however. Otherwise the order of the Menu Bar Chart will constantly change!

Finally, disable Tooltips as they are of no real added value. Do this by clicking on the Tooltips Property on the Marks Card and then basically just deselecting all the checkboxes.

Add the Worksheet to the Dashboard

Now that we have our menu bar worksheet in place, we can add it to the dashboard and subsequently make it behave as a control for our parameter. Adding it to the dashboard is fairly straightforward. Just drag the worksheet to the View. Then delete the unnecessary containers, resize the containers, and finally hide the worksheet titles.

Set up a Change Parameter Action

In order to use the recently added worksheet as a menu, we need to set up a Change Parameter Action. While on the dashboard tab, click the Dashboard menu on the actual menubar, and then click on Actions…, after which Dialog Box will pop up. Click on Add action and select Change Parameter… from the menu. Rename the Action appropriately and select the dashboard from the Source Sheets dropdown. After which you can select the menu bar chart checkbox and deselect the other checkboxes from the Source Sheets list.

Finally, set the target parameter. In our case that would be [PAR Island]. Don’t forget to also set the Source Field, which should be [Name Island] in the example. Additionally, you should make sure the Run action on radio button is set to Select, and the Clearing the selection will radio button is set to Keep current value. This is often already the case.

Congratulations the dashboard is set up for use! The only thing that is still a bit annoying is that all the other choices in the menu are greyed out when we select an island:

This brings us to the last step.

Adding a Filter Action to prevent greyed out menu items

The only thing still left to do to complete our example dashboard is adding a Filter Action. A Filter Action that is run after the parameter is set, can override the selection made by clicking an island (and thereby setting the Parameter). If the Action is set to filter the worksheet on the basis of something that is not reflected in the View, nothing really happens. However, as a side effect the previous selection is undone! This is a very useful hack, as we can prevent that annoying greying out of menu items with it. Note that we don’t need the greying out anyway since color is used to distinguished what is selected and what is not selected.

To set up a Filter Action do the following: as in the previous example go to the dashboard menu on the top menubar. Click on Actions… and start the configuration in the Dialog Box. Choose Add action, but this time select Filter… from the fly-out menu. Supply an appropriate name, select the menu bar chart worksheet from the dashboard in the Source Sheets section. Then select the worksheet with the menu bar chart from the Target Sheets dropdown. Make sure Select is chosen from the Run action on radio button, and Show all values is chosen from the Clearing the selection will radio button.

Choose a Target Field that is not reflected in the View

Now—and this is the important part—select Selected Fields from the Filter radio button and fill in the little table below. Pick the top row and click on Click to add. There you should select the relevant Field name, in our case: [Name Island]. For the Target Field you can basically select anything as long as it is not reflected in the corresponding View. So we pick [Category] for now. Select OK twice to close and save both Dialog Boxes and behold the effect on the dashboard!

For an alternative approach of this last technique and a good explanation check out this blog by Tim Bakker.

Conclusion

I hope you enjoyed making a Menu Bar Chart in Tableau and picked up some techniques along the way. Make sure to visit our site The Information Lab NL to see more blog posts, training and consultancy services regarding Tableau, Alteryx and Snowflake.