Filters play a crucial role in allowing users the flexibility to manipulate dashboards to their liking. Multi-select filters can be particularly useful when the stakeholder requires the flexibility to include or exclude certain values from the Tableau visualization. Utilizing filters has its own set of limitations, such as the inability to filter across data sources or customization of the user experience. Traditionally, relying on parameters allows you to both customize the UX and filter across multiple data sources but does not allow for a multi-select option. Alternatively, sets, and associated set controls, have been used to allow for multi-select, but this option does not allow you to deselect without resetting the entire experience.

At Playfair Data, we have developed a new approach that allows the engineer full flexibility and customization over their multi-select filter, including the use of shapes to indicate selection vs. de-selection, a UX workaround to automatically deselect a dimension member, Dynamic Zone Visibility to show and hide the drop-down menu, and the ability to filter across data sources. It may sound too good to be true, but keep reading to learn how to wow your stakeholders with this new innovative UX!

Join 25K+ leaders using Playfair Data to make better decisions.
 

This field is for validation purposes and should be left unchanged.

By the end of this tutorial, you will be able to build a custom multi-select dropdown menu powered by a parameter that works across data sources.

Multi select filter in Tableau

 

View / Interact / Download

 

Before jumping into the tutorial, it is important that you understand the high-level explanation of what these step-by-step instructions aim to achieve–namely a customizable multi-select drop down menu using a parameter filter.

The traditional approach to parameter filters uses the List option for the allowable values within the parameter settings, which restrict the user to only have the ability to choose the specified options within that list. Furthermore, with the List option, the user can only choose one item from the list at a time, therefore restricting the possibility of multiple selections.

How to Make Custom Menus in Tableau

 

Build the parameters and calculations needed for a multi-select filter in Tableau

Start by connecting to the Sample Superstore dataset. Once connected, we’ll start by creating all the parameters and calculations needed to build the multi-select filter.

‘P. Captured Value’. This parameter will be an blank string parameter, make sure Allowable values = ‘All’ and the ‘Current value’ is empty. This parameter will later store and feed the visualization dimension members based on the selection of a custom drop down menu that we’ll create later on.

Captured Value parameter

‘P. DZV | Drop Down Menu’. This Boolean parameter will control whether the dropdown menu is shown or hidden using Dynamic Zone Visibility.

Drop Down Menu parameter

‘DZV | Drop Down Menu’. This calculation will be used in a parameter action to switch the value of the Boolean parameter between True and False when the drop-down selector is selected.

IIF([p. dzv | drop down menu] = TRUE, FALSE, TRUE)

‘Append or Delete, Sub-Categories’. This calculation will be used to append a Sub-Category selection from the custom menu that we’ll create to the string parameter.

IIF(CONTAINS([p. captured value], [Sub-Category]), REPLACE([p. captured value], ‘,’+[Sub-Category],”), [p. captured value]+’,’+[Sub-Category])

‘Append or Delete, All’. This calculation will be used to append or remove the All selection to the string parameter. The first line of logic will check to see if there is a comma appended at the end of All. If there is a comma, then that will indicate that a Sub-Category has also been appended to the string, in which case we want all the Sub-Categories that have been appended to the string replaced with All. If the parameter does not contain All, then we will replace all values in the string with All. Then the last ELSE statement will replace anything in the string parameter with a blank to remove all selections made.

IF CONTAINS([p. captured value], ‘All,’)
THEN ‘All’

ELSEIF NOT CONTAINS([p. captured value], ‘All’)
THEN ‘All’

ELSE ”
END

‘All Selection’. If the parameter contains “All,” (with a comma) then it will show that not all Sub-Categories have been selected. If it contains “All” (without the comma) then it will show that all Sub-Categories have been selected. The last ELSE statement will show that not all sub-categories have been selected.

IF CONTAINS([p. captured value], ‘All,’)
THEN ‘◻’ + ‘ ‘ + ‘All Sub-Categories’
ELSEIF CONTAINS([p. captured value], ‘All’)
THEN ‘☑’ + ‘ ‘ + ‘All Sub-Categories’
ELSE ‘◻’ + ‘ ‘ + ‘All Sub-Categories’
END

‘Menu Filter’. This calculation will parse through the ‘p. captured values’ parameter we just created and extract any Sub-Category values that have been appended.

IF CONTAINS([p. captured value], ‘All’)
THEN NOT CONTAINS([p. captured value], [Sub-Category])
ELSE [Sub-Category] = IF CONTAINS([p. captured value], [Sub-Category]) THEN [Sub-Category] END
END

‘Menu Selection’. This calculation will return either a check marked Sub-Category name or an unchecked Sub-Category name (using unicode text for the check marks). If the calculation ‘Menu Filter’ returns True, then the Sub-Category will be check marked, but if ‘sub-category filter’ returns False, then the Sub-Category will be unchecked.

IF [Menu Filter] THEN ‘☑’ + ‘ ‘ + [Sub-Category]
ELSE ‘◻’ + ‘ ‘ + [Sub-Category]
END

‘Drop Down Menu Text’. This calculation will be used as the text for what has been selected in the custom drop down menu. This logic will return “All Sub-Categories” if all have been selected, “Multiple Values” if more than one but not all have been selected, a single Sub-Category if only one has been selected, and “None Selected” if nothing has been chosen from the drop down menu.

IF SUM({ FIXED : COUNTD([Sub-Category]) }) = COUNTD(IF [NEW.menu filter] THEN [Sub-Category] END)
THEN ‘All Sub-Categories’
ELSEIF
COUNTD(IF [NEW.menu filter] THEN [Sub-Category] END) > 1
THEN ‘Multiple Values’
ELSEIF COUNTD(IF [NEW.menu filter] THEN [Sub-Category] END) = 1
THEN MIN([Sub-Category])
ELSEIF COUNTD(IF [NEW.menu filter] THEN [Sub-Category] END) = 0
THEN ‘None Selected’
END

 

Build the sheets for a multi-select filter in Tableau

Create a simple bar chart visualization, which will be used to demonstrate the multi-select filter in action. Name a new sheet ‘Bar Chart’, place Sub-Category on the Columns shelf, SUM(Sales) on the Rows shelf, and the ‘Menu Filter’ calculation = True on Filters.

Bar chart in Tableau

Create a new sheet called ‘Drop Down Menu’. Place Sub-Category on the Rows shelf, the ‘Menu Selection’ calculation on the Text property of the Marks card, and the ‘Append or Delete, Sub-Categories’ calculation on the Details property, and the ‘Menu Filter’ calculation on the Color property of the Marks card. Click into the Color property and adjust the colors to make the selected state black and the unselected state gray. Hide the Sub-Category Header and fit the view to Width. Format lines & borders.

Multi select menu in Tableau

Open a new sheet and name it ‘All Value’. Place the “All Selection” calculation on both the Text and Color properties of the Marks card. Click into the Color property and adjust the colors to make the selected state black and the unselected state gray. Place the ‘Append or Delete, All’ calculation on the Detail property of the Marks card. Lastly, double-click into the empty space in the Marks card to create a new ‘pill’ and type TRUE. Repeat to create a second pill and type FALSE. 

All value for multi select filter in Tableau

The last sheet we need to create is the drop-down selector. Start by opening a new Sheet and name it ‘Drop Down Selector’. Place the calculation ‘DZV | Drop Down Menu’ on the Detail property of the Marks card, the ‘Dropdown Menu Text’ calculation on the Text property, and then double click into the blank space at the bottom of the Marks card and create TRUE and FALSE calculations. Change the mark type to Shape and choose a dropdown menu shape from your Shapes folder. Change the size of the shape as necessary.

Drop down selector in Tableau

 

Assemble the view in Tableau

All of the pieces have now been built, so we just have to assemble the view, apply Dynamic Zone Visibility, and create the necessary Dashboard Actions. Drag all of your sheets into the dashboard view and size them appropriately as seen in the image below.

Assembling the view in a Tableau dashboard

Float a vertical container onto the dashboard and stack the ‘all value’ and ‘drop down menu’ sheets inside it as seen in the image below. Select the vertical container, navigate to the Layout pane, checkmark ‘Control visibility using value’, and choose ‘p. dzv | drop down menu’. This will apply Dynamic Zone Visibility to your dropdown menu, which is being controlled by the Boolean parameter selected. When the parameter is True, the menu will be shown, but when it is False, the menu will disappear.

Drop down menu with dynamic zone visibility

How do Do Advanced Dynamic Zone Visibility in Tableau

Now we need to create dashboard actions to bring this visualization to life! The first parameter action will append or delete the Sub-Category selection made from the dropdown menu to the string parameter. At the top navigation, select Dashboard, select Actions…, select Add Action, then choose Change Parameter. Name the parameter action ‘append or delete | subcategories’, choose ‘drop down menu’ under Source Sheets, Run action on ‘Select’, choose ‘p. captured value’ under Target Parameter, choose ‘append or delete, subcategories ’ under Source Field, then choose ‘None’ for Aggregation, select OK. 

Append or delete Sub-Category

The next parameter action will append or delete ‘All’ to the string parameter when selected. Name the parameter action ‘append or delete | all value’, choose ‘All Value’ under Source Sheets, Run action on ‘Select’, choose ‘p. captured value’ under Target Parameter, choose ‘Append or Delete, All Value ’ under Source Field, then choose ‘None’ for Aggregation, select OK. 

Append or delete all values

Create a new parameter action called ‘dzv | drop down menu’, which will be used to switch the Dynamic Zone Visibility value between True and False when the ‘drop down selector’ sheet is selected. Follow the instructions highlighted in the image below.

Dynamic Zone Visibility in Tableau

We will next create three filter actions, which will be used to automatically deselect the ‘drop down selector’, ‘drop down menu’, and ‘all values’ sheets. Follow the directions in the images below for each of the three filter actions.

Deselect filter action drop down menu

 

Drop down selector deselect filter action

 

All value deselect filter action in Tableau

Once the dashboard actions have been completed, all that is left to do is test it out and make sure the multiple values dropdown menu is working as expected. And that’s it; I hope you enjoyed and learned something new from this tutorial. As always, feel free to reach out to me if you have any questions or comments about this tutorial. 

Multi select filter in Tableau

Learn to navigate uncharted waters.

Upgrade to Core or Premium benefits to take your data skills even further.

Happy Vizzing,
Dan Bunker
[email protected]

Become a member

Get access to this related video & more!

Become a Member

Related Content

Ryan Sleeper

Create custom row-level calculations from text using string functions Learn how to access all the different string functions from within…

Ryan Sleeper

Make filter results more predictable by basing them on row number Do your filters ever return a result you weren’t…