In my last blog, I showed you a few examples of using calculated fields to colour your Tableau dashboard. This time I’m going to illustrate how you can enhance this method by provided the end user with more flexibility. To do this, I will use dynamic reference lines and parameter actions in my NBA dashboard example.

Dynamic Reference Lines

Once again I have a scatterplot showing how each NBA team performed on offense and defense last season (the colouring uses a calculated field that I demonstrated in my last blog). The above reference lines are based on the median value. The issue is these values are static, so they would not change if the user decides to filter the view. What if I’m only interested in comparing western conference teams? I would want the reference lines to show median values for western conference teams only, rather than all teams. To circumvent this problem, we can use a window calculation. Window calculations only take into account values in the view, and then aggregate based on them. For this example, a window median calculation will do the trick (for more information on how this calculation works, click here). To update my reference lines, I first need to create the window calculation, as illustrated below:

Note that this is a default table calculation, of which window calculations are a subset. As such, it is important to make sure all fields in the expression are aggregated. If I didn’t include the SUM function, there would have been an error. The same process applies to the other reference line, just using defensive rating instead. Next we need to edit both reference lines to use these calculations. This process is demonstrated below:

The main thing I want to point out from this is to make sure the calculations are in the level of detail, otherwise they won’t be available to you when you edit the reference lines. As you can see at the end of the GIF, the reference lines are now dynamic!

Parameter Actions

The window calculation method certainly enhances the visualisation, but it could still use some more interactivity. What if the end user wants to see how their favourite team compares to the rest? I want to be able to click on any given team to use them as the origin for the reference lines. This is very easy to do, thanks to parameter actions.  First, I need to edit the reference lines to be based on the offensive and defensive rating parameters. The process is the same as in the above demonstration, except the parameters do not need to be in the level of detail. Then it’s as simple as setting up the parameter actions. This process is demonstrated below:

Note how I had to create a parameter action for each parameter. You can only control one parameter per parameter action. Also, because the reference lines are based on the parameters, they dynamically change the origin depending on where I click. As you can see at the end of the GIF, the end user can now click on any team and the view updates accordingly (if you look closely you will notice that the parameter values update on the right-hand side). Thanks to parameter actions, the visualisation is now much more interactive!

These examples show the power of dynamic reference lines and parameter actions in Tableau, and yet they only scratch the surface of what is possible. Hopefully you found this blog to be useful, and if you want to learn more about parameter actions, try this link.