Generic Data Source for Parameters

I tend to use a lot of parameter actions to act as selections/toggle in my dashboards, and have been thinking about how to make them easy to work with.

The two ways I have used in the past to create a toggle/selection is to:

  1. Use data already in your data source to create the toggle if it exists, or create calculated fields to make the data
  2. Create a small separate data source with the data in it.

I have found number two to be my favourite, and it works well when your toggle is not directly related to your data. However I have found using this method a bit of a pain when I need to keep updating the data source to add extra toggle functions, or items to a selection, as you need to re load the data in.

So instead I have started using a ‘Generic’ data source for my parameter actions which I can load in once, and then make any changes I need within Tableau. The data source looks like this:

I will use this in conjunction with another simple data set, in order to show the example, this data set looks like this:

I want to simply have a colour toggle which changes how a chart looks, so I get something that does this:

First I want to set up my colour selector as a separate sheet, using the generic parameter data source. I set up a parameter called pColour which will control the colour change:

And then I start setting up some calculations in my generic data set (note I converted my data to be a string dimension, rather than integer). The first one is ‘ParameterName’ which I use to filter on the parameter I am interested in (or filter out nulls):

At the moment I only have one parameter, so I will label the first two elements of data as ‘pColour’. Then I will create a ‘SpecificName’ field which will contain the actual data I want to select – in this case Red and Blue:

With these set up I can then set up my selector sheet:

Note the ParameterName: pColour filter – this means it excludes any nulls, and also any other parameters we may add in future. Also note the ‘True’ field and ‘False’ filter – these are used in the dashboard which you will see later.

This then gets put on a dashboard along with a simple chart based off the actual data source:

I then add a parameter action based off the selector sheet that updates the pColour parameter, this passes the ‘SpecificName’ field to the parameter:

This will update the parameter, but won’t do anything else yet as we need to add a field to the actual data source which will update based on the parameter, which I can then use to change the chart colour:

This field simply goes onto the colour shelf of the main chart, which you can then recolour based on what has been chosen. Now the parameter action works:

Note: This also uses a filter action trick to deselect the selector when the user selects it (as we don’t need it to remain selected). This action looks like the below:

This is a neat trick that essentially passes a ‘True’ field through to the same sheet you selected from, but with the Target as ‘False’. This essentially filters everything off the view, but by choosing ‘Show all values’ on selection clear, this puts the view all back in again.

This might seem a long winded way of doing it, but now it is set up it is very easy to add extra colours, or even extra selectors. To add an additional colour I just need to add a couple of lines to the following fields, and update the main chart colour:

To give the below:

And to add a different selector, I can add additional rows to the same fields, but this time changing the parameter name. For this example I am using an Asc/Desc option:

Then I can set up another selector sheet, filtering the ParameterName on ‘pAscDesc’ and create the selector as before. This will update a parameter called ‘pAscDesc’.

I also want a new field in the main data source that I can sort on, based on this parameter:

This just reverses the value based on the Asc/Desc flag.

This can be added to the dashboard in the same way as the colour selector and you now have a two selector dashboard, with the selectors both running off the generic data source:

The only additional thing I did with the change order selector, is to add a flag to the generic data source to highlight if the parameter is selected or not, so I could get the grey and blue colouring.

The Tableau Public viz is here:



One thought on “Generic Data Source for Parameters

Leave a Reply

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

You are commenting using your 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