Dynamic Categories and Legends in Tableau

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.

categories and legends in tableau

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.

  1. 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.

  1. 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:
categories and legends in tableau

  1. Now drag the Category pill to the Color shelf and to the Rows shelf, this will be the result:

  1. 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:

categories and legends in tableau

  1. This will be the result.
    You can also bring the Sales pill to the Label button, format the axis and the values, colours, etc.


How to guides for Tableau beginners