Do you know how to create Dynamic Categories and Legends in Tableau?
Follow along to the video or check out the steps below.
Dynamically selecting the measures values and legends.
If you want to compare different categories values in a chart and want to select them dynamically, this is a simple and efficient way of doing it.
- Create a new parameter called “Income vs” and:
Data type: String
Allowable values: List
Fixed: Add values from > Category (or the dimension you want to be selectable by the user). In this case, I deleted the “Income” category in the “List of values”, as it will be always displayed.
Right click this parameter and select “Show Parameter” to be displayed for selection.
- Drag the Value pill and drop it in the Columns shelf. Drag the Month pill to the Rows shelf (Month pill, in this example, is a calculation with the following formula: DATE(DATETRUNC(‘month’, DATE(MID([Path], FIND([Path], ‘/’) + 1, 10))))).
Right click the month pill and select MONTH (the one with month and year) and then right click again and select Discrete.
This will be the result:
- Now drag the Category pill to the Color shelf and to the Rows shelf, this will be the result:
- Create a new calculated field named “Show Me Category” with the following formula:
IF [Category] = [Income vs] OR [Category] = ‘Income’ THEN 1 ELSE 0 END
This field must be converted to Discrete.
Use it on the Filter shelf and select the 1 value:
- This will be the result.
You can also bring the Sales pill to the Label button, format the axis and the values, colours, etc.