Parameter Actions (Hands-On!) in 3̶0̶ 45 Minutes

In a year of great new feature releases for Tableau, parameter actions are the single most powerful and versatile addition. In fact, one might say they have a number of superpowers that allow them to accomplish a variety of useful functions. This post aims to explain when and how to use parameter actions, by going through their superpowers one by one and explaining the ways you can use these superpowers. Along the way, I’ll discuss differences between set and parameter actions, when you’d use parameter widgets (controls) versus parameter actions, and the awesome but somewhat unheralded new ability that prevents your parameters from getting out of date.

There’s an accompanying workbook with the examples used in this post, plus step-by-step instructions to creating 4 different views using parameter actions. You’ll need Tableau Desktop 2019.4 or later to open the workbook. All the examples use Tableau’s built-in datasources (either superstore or World Indicators).

I’ve adapted this guide from a talk I gave at the Boston Tableau User Group originally titled “Parameter Actions in 30 Minutes”, but I guess that time was a bit optimistic in reality.

Many thanks to Kevin Flerlage, Ken Flerlage, Lindsey Poulter, and Bethany Lyons, whose writings and workbooks inspired and informed much of the content herein.  Thanks to Jessica Yan for helpful comments when previewing this presentation.

Introduction

This diagram is based on a similar one by Bethany Lyons

Filter, set, and parameter actions have the same general workflow: the user selects, hovers over, or menu-selects one or more items on a view, and that/those selection(s) are captured in an item (a filter, set, or parameter) where they are used for different purposes. Filter actions are only able to create filters. The amazing thing about set and parameter actions is that the selections can be referred to in calculated fields, and can then be placed anywhere in a view – on filters as well as columns and rows, pages, mark properties (color, size, text, detail, and tooltips), and even reference lines.

While set actions and parameter actions are very similar in the way mentioned, a major distinguishing feature is that sets can contain multiple values at one time, while parameters contain one and only one value at any given time.

undefinedSuperpower 1a: The ability to refer to user selections in calculations, and on shelves and cards

undefinedSuperpower 1b: The ability for the user to change selections without leaving the viz

The first set of examples (the yellow tabs in the workbook, through EXERCISE 1) actually demonstrates the two most fundamental superpowers of parameter actions, which were shown in the diagram above. The use cases that demonstrate these most clearly are those where the user hovers over a mark on a graph, and marks with that value are highlighted or otherwise customized in some way. These customizations of the indicated mark include showing more information, changing the size or shape, adding highlight color (much more customizable than the built-in highlight action), or highlighting all the marks that have the same dimension value as the indicated mark.

What’s happening behind the scenes is that the user hovering over the mark triggers the previously created parameter action, which tosses the value of the field specified in the setup (e.g. the particular sub-category value) into a bin that can hold a single value (the parameter). This parameter value is referred to by calculations placed on the color, size, label, etc. properties of the viz, so that these properties change for different marks as the parameter value changes.

Go ahead and play around with the first set of examples. Note that while you technically could accomplish the parameter value change by having the user select a value from a parameter widget, it would be a completely different, and inferior, workflow for the user. They’d have to leave the viz to make the selection, instead of having the selection happen organically as they explore. In addition, since hover selection inherently selects only a single value, I favor using parameter actions over set actions, which can hold multiple values and can be (in my opinion) less straightforward than parameter actions when working with a single value. Therefore, for these kinds of use cases I think parameter actions are the way to go.

The last example in the set is one in which the user can click on the graph and set the reference line to that location. There are 2 special features of this particular example – first, it shows that numbers can be used in parameter actions just as well as text, and second (if you dig into how it was made), the parameters can be referred to directly in the reference line dialog – no need to wrap it in a calculation.

Setting up Parameter Actions

EXERCISE 1 will guide you through creating a scatterplot of Sales versus Profit by State, whose marks change shape, get larger, and show a label when a user hovers over the mark. There are very detailed step-by-step instructions in the workbook, which I won’t repeat here. However, this is a good time to go over the high-level summary of how to create parameter actions:

  • Create the view(s) (sometimes there’s a separate source view)
  • Create the parameter
  • Create the parameter calculation(s)
  • Add the parameter calculation(s) to the view(s)
  • Create the dashboard, if necessary
  • Create the parameter action (Worksheet > Actions or Dashboard > Actions)

One basic calculation is used again and again in these vizzes – a simple “Is Selected Field Name that is defined as Field = Field Parameter Value (e.g. calculation “Is Selected Sub-Category”, defined as [Sub-Category] = [Sub-Category Parameter]). This creates a boolean field. If you drag that onto color, size, etc., you can define your settings for the selected parameter value versus everything else (TRUE versus FALSE). Label calculations have a slightly different form, e.g. the sub-category label is defined as IF [Is Selected Sub-category] THEN [Sub-Category] END

Go ahead and walk through EXAMPLE 1. The steps here are very similar in all of the exercises.

undefinedSuperpower 2: The ability to use values not specified by any field in your datasources

Sets are inherently tied to a field value in your datasource; they are created from a particular field, and they can never contain values outside of that field. Parameters, on the other hand, can be created from any list of values you desire (or no list at all, as we’ll see later), even if they’re just typed into the setup dialog. Parameters don’t “belong” to any one field or datasource; they “belong” to the entire workbook, and can be invoked to influence vizzes from any datasource in a workbook.

The major use cases for this are chart swaps, date range selection, toggling annotation, etc. – cases where users customize their viewing experience. Examples are in the red tabs of the workbook. The values for these parameters — “Bars” versus “Line” for the chart selection, “Last Year/Month/Week” for a date range selection, etc. — are defined separately from your datasources.

You might have already accomplished such actions using parameter widgets, which is still a viable option here. It’s easier to set up than parameter actions – all you have to do is define your list in the parameter setup screen itself. And since you need a separate view anyway to create your buttons for the parameter actions, the user experience of going outside the target viz to click a widget selection versus a button is pretty similar. However, parameter actions do allow you to use prettier, customized buttons for your selections. And as Ken Flerlage pointed out, this isn’t just cosmetic in many cases; for example, on mobile the parameter widget options can be difficult to select. I’ll call these use cases a tossup between parameter widgets and actions depending on the exact use case, with set actions not really a viable option here since they’re tied to one field in one datasource.

The extra step you have to take is to create the buttons on a separate sheet. Perhaps counter-intuitively, you can’t use the parameter list itself to create the buttons, since you can’t drag parameters onto rows/columns, and even if you could you would only see one value at a time. You need the ability to create ALL your buttons at once. Luckily, there’s a very easy way to capture a list of items whose members can all be displayed at the same time – it’s to create a (tiny!) datasource to store your values. (I’m not thrilled that it clutters up my datasource list for a few values, but that’s not a big problem). First list your values, one per line with a single-word header at the top, in your favorite text editor. Copy that list, and paste it into a blank worksheet in Tableau. A new datasource (with a name like “Clipboard_1234”) magically appears in the datasource list, containing your field and all of its values. Rename the darn thing to something useful, and go ahead and use that sheet to make your buttons, which can be as simple as circles with text, or customized using button shapes on the shape pallet. Go ahead and try it with EXERCISE 2.

One last comment about creating the parameter action – while by default the scope of a new parameter action is set to the dashboard you’re creating it on, you can change it to a datasource or even the entire workbook by changing the selection in the dropdown shown. “All” means the parameter action can be triggered from anywhere in the book; if you select this option, you can further customize the exact worksheets and dashboards they apply to (be aware that sheets created after the parameter action creation automatically get checked off on the list; you can go back and change the selections). Here I selected the buttons’ datasource, so that I don’t have to make a new parameter action each time I want to use the buttons, but I don’t have to worry about unchecking boxes for new sheets.

undefined Superpower 3: The ability to allow the user to make their selection from a view that contains more information than a parameter list.

Both of the views above allow the user to select a country and then view the percent of total world population and CO2 emissions for that country. The parameter widget on the left certainly allows the user to select a country from a list. But which countries do they want to choose? All they have to go on is the name of the country, so finding interesting items is just a shot in the dark of clicking around until something interesting is revealed. In the view on the right, the user selects countries from a map that already color codes the relative CO2 emissions from each country. So they immediately might want to look at the United States with the darkest color, and clicking would reveal a percent of total CO2 emissions far higher than the percent of total population. Or China, whose percents of total are approximately equal. With parameter actions, the selection tool is an inherent part of the user’s exploratory experience, and makes for more organic and efficient user workflows on the dashboard.

The examples in this section of the workbook (blue tabs) are the types of use cases you’re most likely to find you use at work over and over again. The user selects a dimension value from one view, and a value for that dimension value is compared in some way with all or other values in the same or another view. You can’t use a filter action, because you need the values outside of the selection for the all/other comparisons. The examples here — percent of total, proportional brushing (selected dimension values magnitude versus total magnitude), selection 1 versus selection 2, difference (or percent difference) from average of the selection — were adapted from Bethany Lyons excellent blog post about set actions. Needless to say, either set actions or parameter actions can be used, depending on whether you want multiple or single selection. However, for the reason explained above, the parameter widget is a poorer choice.

EXERCISE 3 should feel pretty familiar to you by this point – no new surprises for setting up this use case.

Superpower 4: The ability to put any value into a parameter, even if it’s not defined when the parameter is created.

Did you ever use a parameter in a dashboard, and then later have to revise the workbook because the parameter list was out of date? I certainly have. Previously you had to create your list when creating your parameter; you could add values from your field of interest, but they don’t update from the field automatically, so you could find yourself making trivial updates. At last month’s Tableau Conference, DevsOnStage announced that automatically updating (dynamic) parameters will come out next year – yay!!! But it turns out that if you use parameter actions instead of parameter widgets, the future is now.

Instead of selecting “List” under allowable values, you can select “All” (see picture at right above). You don’t need to define your values ever – when you set up your parameter action, the field value you specify is sent over into the parameter bin. That’s it! With parameter actions, you already don’t need to worry about lists getting outdated. So if you’re using parameter actions and not widgets for values related to datasource fields, I recommend using the “All” option. The use case goes solely to parameter actions here — not set actions or widgets.

Wait, aren’t we entering the Wild West here? What’s to prevent you from sending over values from many different fields into the same parameter? Well, nothing will prevent you from doing that – you’ll have to self regulate. 🙂 Name your parameters and parameter actions clearly so you don’t get confused. I couldn’t think of any use case where you’d want different fields going into the same parameter. If any readers of this blog can point to one, I’d love to hear about it!

However, Kevin Flerlage did have a use case for using a button to add a value into a parameter that doesn’t match any of that parameter’s intended field values. He used a “NONE” button that sends the value “NONE” into a parameter; since “NONE” does not match any values for that field in the datasource, it effectively clears out the parameter. What a clever way to use the new “All” feature! The last section of the workbook (teal tabs) include both Kevin’s (reproduced) example, as well as EXERCISE 4 that leads you through a slightly different usage of the NONE button. It’s interesting to note that since you can manually type any string, including “NONE” (you need to include the quotes), into the Marks section of a worksheet, it’s not even necessary to have any datasource fields on your NONE button source worksheet at all, as in the example in the workbook.

Conclusion and Acknowledgements

So that’s it in a nutshell! This is my first instructive blog post, and I appreciate any feedback you have.

Many thanks to Kevin Flerlage, Ken Flerlage, Lindsey Poulter, and Bethany Lyons, whose writings and workbooks inspired and informed much of the content herein.  Thanks to Jessica Yan for helpful comments when previewing this presentation. And of course thanks to Will, Dustin, Kate, and the rest of the Boston TUG community for giving me my first opportunity to present. I had a blast, and I hope there’s more opportunities to help out down the road!

The superman icon was obtained from Flaticon.

Published by Susan Glass

My current work passion is data analytics in the service of creating insights that make significant improvements for the business. My outside passions include word puzzles and games (I started doing the MIT Mystery Hunt when the puzzles were distributed on paper), biking, and of course my family and friends.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website at WordPress.com
Get started
%d bloggers like this: