Making a User Friendly Custom Multi-Selection Filter

While working on a Makeover Monday Dashboard, I thought of an idea in making a Multi Select Parameter. However, I ended up finding out how to make a custom filter tool.

The data used for this week is the Caffeine data. I was trying to find a way to compare the caffeine of both cappuccino and espresso with an option to see just the cappuccino or just the espresso. I can use Tableau multi selection filter, however I don’t want to include the [All] Check box and anything else that's not the 2 categories I want to compare. Using only parameters is out of option because I can only select one option at a time, thus I turned to google to see if there are any options.

Now, I can say goodbye to Checks and Boxes, thus introducing the Custom Multi Select Filter!

Here, we have a look at the original Tableau Multi-Selection filter. One feature not a lot of people like about it is that it displays all the options when not all of it may necessarily be used. In other words, it’s showing options without any relevance.

I will demonstrate how to make a custom multi select filter using superstore data. Here we will be filtering out variables in the [Sub-Category] field.

First, rename sheet1 to “Sub-Categories”. We are going to compare the sales in [Sub-Category] over time. Drag the [Sub-Category] pill into columns, Drag the [Sales] pill into rows, and drag the [Sub-Category] pill into the details.


Make a parameter titled “Sub-Category Parameter” that takes in all values in a string format (or the data type you need).


Next, make a Calculation Field titled “Parameter True / False” that returns true when the [Sub-Category] contains the string in the Sub-Category Parameter. Make sure the data type of the [Sub-Category] is the same as the parameter.



Then, make another Calculation Field titled “Parameter Action” that writes the [Sub-Category]’s name into the parameter. This is a “IF” condition that checks to see if the “Sub-Category Parameter” contains the value in [Sub-Category] and rewrites the value of “Sub-Category Parameter”.


Add the parameter “Sub-Category Parameter”, and the fields [Sub-Category] and “Parameter Actions” into the filters. Have it set to all for now. It will get changed later. Leave it as it is. This will be changed later.


What we had created for now is a filter that returns the value presented in the parameter. However, we had yet to make anything affecting the parameter. Now open up a new sheet and name it “Custom Multi-Selection Filters”. We are going to make our selection (multi custom filter here).

For this sheet, drag the [Sub-Category] pill into rows and set the mark to Circle, Square, or Shape. Then we add the [Sub-Category] in the filter option. Keep the ones you want to compare with checked in. Here I kept Accessories, Appliances, Art, Binders, and Bookcases.


Here we first make 2 calculation fields, one titled “True” returning only TRUE, and one titled “False” returning FALSE. These 2 fields are there to indicate which of the sub-categories are being shown.


In Marks, add “Parameter True” to Colors, “Parameter Action” to details, “True” and “False” to details.

In order to make this work, we need to add in a dashboard action. Create the dashboard and drop in both sheets.

On the top left, go to Dashboard → Actions and add in a Filter Action titled “Deselect”. This action here deselects the item when you select it the second time.


Have source sheet be the “Custom Multi-Selection Filter” and have the target Sheet be “Sub-Categories”


At the bottom of the add filter action window, in the filter, select “Selected Fields”.

Click to add in the field “True” in the source field. Then have the target field of True, select the field “False”.


Click |Okay| and add in a new action Changed Parameters and titled it “Selection”.


In the “Selection” action parameter, have the source sheet be “Custom Multi-Selection Filter”. Set the target parameter be “Sub-Category Parameters” and the source field be “Parameter Action”.


Once those actions are set up, go back to the dashboard and select an option from the “Custom Multi-Selection Filter” sheet.


Once it changes color, go into the “Sub-Categories” sheet, right click “Parameter True / False” in the filter box and edit the filter. Have only the True box checked in.


In order to customize the “Custom Multi-Selection Filter”, go to the sheet, change the marks to shapes and import your own shapes in.

However this is done, you can also just make a table, go to the dashboard and use the action “Set as Filter”. The tableau shortcut crtl+”mouse 1” will multi select things for you. Sadly I learn about this later on but hey, not every user and clients will know about that shortcut. Perhaps this can be seen as a user friendly option rather than developer friendly option.

Resources: https://www.youtube.com/watch?v=M1I5BwXL5UY&t=523s

Author:
Hang Chen
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab