In this blog I'm going to demonstrate how to make dynamic measures on Tableau which will allow us to switch between two different measures. I will do this using the Sample Superstore Data.
- To start, we need to open up a blank worksheet on Tableau.
2. Drag the 'Order Date' into the Columns table. We need to change this to a Week by clicking the little arrow to the right of our 'Year(Order Date).
3. Next we need to make a parameter which will allow us to switch between our two chosen measures. You can find this option in the down arrow at the top of the data pane. Once chosen, you can rename you parameter to 'Dynamic Measure' and change the data type to 'String'. Under Allowable values, select 'List' and type in your chosen measures. For this demo we will use 'Sales' and 'Profit'. NOTE: these must be written the same way that they appear in the data set i.e with capital letters.
4. Once created, click on the arrow beside our 'Dynamic Measure' (this can be found in the Parameters pane) and select 'Show Parameter'. This will be crutial later.
5. Next, we need to make a calculated field so that our selection will be interchangeable. To do this, select the 'Create Calculated Field' option which is above the 'Create Parameter' option, as used above. Here we can call it ' Dynamic Measure Calculation' and enter in what you want to happen once we selected each of our parameters - 'Sales' and 'Profit'. Once complete, click OK.
6. Drag this new Calculation onto the Row shelf and this should change automatically to a Sum - this is correct!
7. To test if your Dynamic Measure has worked, simply click on either 'Sales' or 'Profit' in your Dynamic Measure Parameter which we chose to show earlier. This can be found on the right hand side of your workbook.
8. To wrap up this demo, there is one more part we can add. Since we have added our calculation and parameter onto the worksheet, we can now use this in our title! Simply, double click on the title and clear what is automatically populated. On the right of this window there is an option for 'Insert' and click on our parameter we made.
9. Now, when we click on our 'Profit' and 'Sales' in our parameter, the title will also change! How cool :)