Here’s the situation: You have multiple measures that you want to view across time, but you don’t want to see all of the measures at the same time. Instead you want the user to be able to pick the measure to view.
Parameters to the rescue!
Andy Cotgreave blogged about user built views in his Data Studio days. In this blog post I will provide the step-by-step directions. The charts types you can create with the technique are seemingly endless, but I’ll go through a simple scenario.
Step 1 – Right-click anywhere in the Measures or Dimensions windows and choose Create Parameter. Create a parameter named “Choose a measure” with the settings below. Note that I am giving this a name that will instruction the user as to what to do.
Step 2 – Find the parameter you just created in the Parameters window. Right-click on it and choose “Create Calculated Field”.
Step 3 – Use a CASE statement to build the calculated field. This field is telling Tableau what measure to use based on the value chosen in the “Choose a measure” parameter.
Step 4 – Add Order Date to the column shelf and your new “Measure chosen” measure to the row shelf. For this example, I’ve expanded the Order Date field to Quarter.
Notice how the y-axis is labeled “Measure chosen”. We’ll clean that up in a bit.
Step 5 – Right-click on your “Choose a measure” parameter in the Parameter window and choose “Show Parameter Control”. It should appear on the upper-right of the window.
Make different selections in the parameter control and notice how the y-axis and the chart change dynamically.
Step 6 – Drag the “Choose a measure” parameter to the row shelf. Again, make different selections in the parameter control and watch the label change.
We’re almost done. Just a bit of formatting remains.
Step 7 – Clean up the chart.
- Right-click on the field that shows the “Choose a measure” value and select “Rotate Label”
- Right-click on the row label and choose “Hide Labels for Rows”.
- Double-click on the “Measure Chosen” axis to bring up the Edit Axis window. Delete the title.
That’s it. You’re final viz should look like this:
If you’re like me, once you saw this technique, you began thinking of all of the possible uses. Play around with lots of different use cases. Try scatter plots, dual-axis charts, bubble charts, etc. You can control ANY of the shelves using parameters. Imagine the guided analysis you can provide your users and the exploration they’ll be able to do on their own. It’s almost like creating a pivot table for them.
If you want a slightly more complex version, I created a scatterplot of NBA franchise values that allows you pick the x-axis, y-axis and size, all with parameters.
Parameters are quite powerful. Leverage them!
Download the sample workbook here.