In one of my previous post,s I wrote about Dynamically Update the ‘Relative to’ section of a Table Calculation, using a parameter.
Now with the release of Tableau 2019.2, and the introduction of Parameter actions, it is possible to dynamically select a member of a dimension as the ‘Relative to’ part of a Table Calculation.
In this blog post, I will explain how to achieve this result.
For this example, I will use the dataset Sample-Superstore.
To begin with, create a parameter using your desired dimension (in this example sub-category). If you are unsure how to create a parameter check my previous post here.
Set the parameter as follows:
The allowable values can be set to either “All” or “List”, just make sure that all members of the dimension are present.
Then drag the dimension on the view.
Drag a measure onto the view (in this example profit).
Right-click onto the measure pill and select Add Table Calculation. If you select one of the following types of calculation, Difference from, Percentage difference from or Percent from you will see a section called “Relative to” appear.
From here you will be able to select the parameter previously created. Make sure to select “specific dimension” in the “Compute using” section, otherwise only the options “First”,”Last”,”Previous” and “Last” will be available.
Now you only need to set up the parameter action. If you are unsure how to do so, check this other post on the subject.
And that’s it. Now clicking on any member of your dimension will set that member as the ‘Relative to’ section of the Table calculation.