Using Icons to Change Parameters (With Parameter Actions)

Adding parameter actions to your dashboards opens up a whole new world of design possibilities! In this post, I’ll demonstrate a way to change parameters by clicking on an icon (instead of the default drop-down or toggle), making use of parameter actions.

You can see the icon menu in action on my Twitter metrics dashboard, which I’ll also be using to demonstrate the process. For this dashboard, I wanted the user to be able to switch between 6 key twitter metrics – engagement rate, retweets, comments, new followers, profile visits, and likes – using the icon interface.

To get started, let’s set up the parameter that we’ll use throughout the dashboard. In some cases, your data source might already contain a field with all the metrics you’ll want to use – if that’s the case for you, you can skip the next two paragraphs and go straight to setting up the page with your icons. In my case, each metric was a separate column (and I didn’t want to pivot my data, for a variety of reasons), so I needed to create a calculated field to show my metrics. You’ll need to add this directly into your data, so that you can use it as a field later.

To add my metrics, I used a calculated field based on an index field in my dataset. (Another option would be to create a separate data table with your metrics, and join it to your data source). Create a calculated field that’s based on a unique field in your dataset, where you assign one value from the index field to each metric you want to use. My calculated field, which I named “Metric Options”, looked like this:

if [Sort]=1 then 'Likes'
elseif [Sort]=2 then 'Comments'
elseif [Sort]=3 then 'New Followers'
elseif  [Sort]=4 then 'Profile Visits'
elseif [Sort]=5 then 'Retweets'
elseif [Sort]=6 then 'Engagement Rate'
end

“Sort” is a unique identifier from my original dataset. After adding this calculated field, each of my metrics will appear once in the “Metric Options” column. It doesn’t matter which records they’re linked to – we won’t be using them to filter in that way.

Now that we have a calculated field, let’s set up the page we’ll use for our icon switcher. Add the calculated field you just made to the text mark card and to the filters card, and filter to exclude “Null”. Then add your index field – “Sort”, in my case – to the columns card.

Looking good! We have our 6 metrics appearing in a sheet. Let’s turn them into icons.

First, you’ll need to find the icons you want to use. Google Fonts has a huge collection of free, nicely designed icons available for download. Once you’ve picked the icons you want, click on them and download the PNG files. (Adjust the settings however you want before you download – since my dashboard is dark mode, I downloaded the white versions of the icons)

In order to use these as shapes in Tableau, we’ll need to add them to our Tableau repository. Open the “shapes” folder inside your Tableau Repository, and copy-and-paste in the PNG files that you downloaded.

(Tip: Your Tableau Repository folder was created when you installed Tableau. If you’re not sure where it was installed, you may have to search your drive to find it.)

Now the icons are ready for us to use in Tableau. Head back to your workbook, and change the mark type from automatic to “Shape”. Then drag your “Metric Options” pill from “Text” to “Shape”

You’ll see that your text marks have changed to shapes. Let’s make them into our cool new icons! Click on the “Shape” card and change the shape palette to “Custom”.

You should see the new icons that you added to your shape folder. If you don’t see them, click “reload shapes”, and they’ll appear. (If you have white icons, like me, you won’t be able to actually see them – I promise they’re there! Hover over the blank spots to find them.)

Go ahead and assign your shapes to the matching metric. (If you have white icons, this might take a little bit of trial and error).

When I return to my sheet, here’s what I’m seeing. Because I’m using white icons, I’ve temporarily changed the background color of my sheet to black so that you can see them – I’ll remove that before I add it to the actual dashboard.

At this point, you can make any style changes you would like. I used the color card to set opacity to about 50% – this makes the icons a little subtler, and gives a nice highlight effect when one is selected. You can also play with size, etc.

We can also hide the field labels at this point so that only the icons are visible. Right click on each header and uncheck “show header”.

Now our graphic is all set up! Go ahead and add it to your dashboard. (If you want to have the icon selector in multiple places, you’ll need to create multiple copies of that sheet – I recommend setting up one all the way before you start making multiples).

(Note: I’ve removed the black background I added for demonstration purposes earlier, and made the background transparent instead.)

Before we can set up our parameter actions, we need to get a parameter going. Head back to a sheet and create a new parameter. I named mine “Metric”. Set the data type to “string”, the allowable values to “list”, and add fixed values from the “Metric Options” calculated field we created earlier. (Or the original field that had all your metric options in it)

Let’s bring it all together! It’s time to combine our icon sheet with the parameter using parameter actions. Head to your dashboard, select “Actions” from the dashboard menu dropdown, and add a new parameter action.

Give it a name you’ll remember, and set the source sheet to be the sheet with your icons. Then set the target parameter to be the parameter you want to change (“Metric”, in my case), and the source field to be the metric options field you used on your sheet.

The selections for “Run action on” and “Clearing the selection will” are up to you – I find that “Select” and “Keep current value” are the most intuitive choices.

With that, your icons should be acting as a parameter swapper! If you want to test it out, you can create a text field that incorporates the parameter name – whenever you click an icon, the parameter name should change.

From here, you can use the parameter in your dashboard however you would like! In the Twitter engagement dashboard, I used a set of calculated fields with my parameter to show and hide sheets – you can learn more about that in my post on chart swappers with dynamic zone visibility.

You might want to use your parameter to show images, create a filter, or something else – there are infinite options with parameters. To see more detail on how I used the metric parameter in the Twitter dashboard, you can download the workbook from Tableau Public and play around with the calculated fields as much as you want.

Thanks for reading – I hope this post helped you see some of the possibilities of parameter actions in Tableau!

Let’s keep in touch! New tips, tricks, and tutorials are posted about once a week – sign up to get them straight to your inbox!

I don’t spam! Read the privacy policy for more info.

One response to “Using Icons to Change Parameters (With Parameter Actions)”

  1. […] you could use icons to change the parameter instead of a default parameter control. Check out this post to learn […]

Leave a Reply

Your email address will not be published. Required fields are marked *