QueenOfData

Set It Up: Parameter Action FUNdamentals (pt. 3/4)

In my last blog post, I talked about Set Actions, the opportunities they offer us in our work with Tableau, and their limitations. Parameter Actions can be possible solutions for those limitations of Set Actions.

Tableau defines Parameters as dynamic values that replace constant values in calculations, filters, and reference lines. Personally, I like to describe Parameters as values floating around in space. They are completely removed from any kind of data source – until you reach from your data source to the Parameter and use it in some way. A Parameter by itself isn’t worth a lot, so you always need to reference it in a filter, calculation or reference line.

Parameters can do a number of things that are difficult or impossible to accomplish with Sets. For example, you can filter or calculate relative to a Parameter. You can, for example, filter on a six-month-span around a date set in a Parameter, or colour everything that contains a string value in a Parameter.

You can also use the same Parameter in combination with any field, in any data source. Since Parameters by themselves are completely removed from your data, you can reference them anywhere in your data. And, of course, you can use them to set reference lines.

Now, let’s take a look at an example. I have three different sheets, originating from different data sources. On the left, we have our classic Superstore. We can see that the Subcategories are sorted descending by Sales, but since the Sales are different in every year, that makes it look a little unclean. I want to be able to set a focus on any one year and sort the Subcategories by the Sales within that year, and I want to colour them accordingly.

On the right, we have the monthly amount pledged by users on Kickstarter, for different years. I want to colour the same focus year that I chose for the Superstore data, and also colour the previous year as a point of reference. And on the bottom right, we find the CO2 emissions again. I want to colour those bars the same way as the Kickstarter lines.

Now, in my trainings I teach a simple acronym here: CAUSE.

  • C reate
  • A pply
  • U se
  • S et up your action
  • E njoy! 🙂

First step in order to use a Parameter, is to create one. I create a simple integer Parameter, call it “Select year” so that users know what to do with it, and allow all values, in the blind faith that my data source will contain a reasonable span of years.

Next comes the A for apply. As I mentioned above, the Parameter by itself is worth nothing, until I reference it in my data. In this case I create two calculated fields (one per data source) in order to find out if the year in my data is the same as the Parameter or the previous year. I then use this field – there’s your U – in the view, by setting it on colour.

Now, this is where the acronym gets a little less helpful in the wake of Parameter Actions. The S used to stand for show, because the Parameter is worth little if the users don’t have access to it. But now, the S can stand for “Set up your Action” instead (hence the title of my TFF talk, “Set it up”). So I set up my action, one originating from the Kickstarter chart and one from the Emissions chart.

The last letter, E, may not be so obvious, but it should be. It’s enjoy! And this gets even more relevant with Parameter Actions. Look how I just have to select a line and the colours will change, both in my line and bar charts.

But wait, what about the Superstore chart? Here I have to start with apply again and create my calculated field. In this case, I don’t want all the bars to simply have the same colour. I want the colour to vary slightly by length of the bar, and I want the bars of my focus year to have a different colour scale. I need two calculated fields for that. One for the Sales of the selected year, and one for the Sales of the other years.

I then drag those two measures onto the same axis, creating a combined axis, and drag Measure Values to Colour. By right-clicking, I can select to have separate colour legends for each measure. That’s where I can set one to grey-scale, and the one for my focus year to a beautiful teal colour. Now I only have to sort my Subcategories by the Sales of selected year field, and there we go.

After apply and use comes S for “set up your Action”, and that’s what I do next. Just go to Dashboard > Actions > Add Action > Change Parameter, and set it up for my Superstore sheet. And then I can enjoy it even more: look how the colours and the sorting changes depending on the field I choose.

One more example might be colouring multiple items. Parameters can only ever take one value, but they are able to react to multi-select, if that is what you choose. Let me show you.

Let’s say you want to colour all the clients starting with some selected initials. I created a small helper data source to visualize a keyboard that users can use to select their initials, and I have created a scatterplot of all the Superstore clients by Sales and Profit. Now I just need a Parameter and a few calculated fields.

Create your Parameter and make it a string value. Then use it in a calculation. If a customer’s initials are somewhere in the Parameter value, I want the field to be coloured by that initial, and everything else should be called “other”. So I set up the calculation and drag it onto colour. I also put the calculation onto colour in my bar chart, and exclude “other”, to see how many clients I have by each initial. The sheet comes up empty for now, but that is perfectly fine.

The same goes for my keyboard. Set up the calculation and drag it onto colour.

Back in the dashboard, I want my keyboard to feed the Parameter I created, so I set up my Parameter Action. It should originate from my keyboard and feet the “Selected initials” parameter. And here is where Tableau asks me for aggregation. If you want your Parameter to only ever react to single selection, then simply choose “None”. But in my case, I want Tableau to concatenate all selected values, so that is what I choose.

Let’s check this out. I’ll simply start by selecting all values, and we can see how colourful everything goes at once. The bar chart is suddenly filled, as well. This is where I can choose appropriate colours. I’ll assign my colours to both palettes. And now I can choose individual values instead. Let’s look at all the customers starting with a T, or at all the customers starting with ASDF. It’s easy and intuitive to use, and Tableau will react to every letter in the Parameter.

So, let’s summarize how Parameter Actions can make our lives a little easier: they can take values from any field in any data source, thus spanning any and all data sources you might use in a workbook. If you so choose, they will aggregate the values you feed into them if you select multiple, and you can use them to colour your marks, set labels, or set reference lines. On the other hand, they cannot take more than one value, even though the new ability to concatenate makes this issue something of a moot point, for string values at least.

Now, the main question left to ask is how can you decide whether to use a Set Action or a Parameter Action? How do you know when to use one over the other? Check out the next blog post to learn more.

Please also check out the following resources on Parameter Actions for more advanced play:

Leave a Reply

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