Display dimensions dynamically in Tableau

When visualising data on Map, it is useful to flip through views without changing sheets. For example, viewing the population of an area by sex or by age.

Parameters in Tableau can be used to replace a constant value in a calculation or filter. By showing parameter control in the viz, viewers can interact with the visualised data directly.

Sample Data

Name of District Council districtMaleFemale
Central and Western98282137671
Wan Chai6707599620
Eastern233542296061
Southern116238147039
Yau Tsim Mong138873171774
Sham Shui Po197878233212
Kowloon City179518231116
Wong Tai Sin187531219271
Kwun Tong312303360863
Kwai Tsing232213263585
Tsuen Wan146412173682
Tuen Mun240321266558
Yuen Long314056354024
North145343164288
Tai Po146038170432
Sha Tin317927372879
Sai Kung223094265943
Islands84985100297

Step 1: Create a parameter

  1. In the Data pane, click the drop-down arrow next to “View data” and select Create parameter
    Select "Create Parameter" using the drop-down button in the Data Pane.
  2. In the Create Parameter dialog, enter the Name.
    Create Parameter dialogue in Tableau
  3. Under Properties, select Integer.
    Select "Integer" under "Data type" when parameter is created.
  4. For “Allowable values”, select List
  5. Enter the “Value” and “Display As” pair.
    Value-Display table in Create Parameter dialog in Tableau.
  6. When finshed, click OK.
  7. The newly created parameter can be found under Parameters at the bottom of Data the pane. Right click on it. Select Show Parameter.
    Select "Show Parameter"

Step 2: Create Calculated Field

  1. In the Data Pane, click the drop-down arrow next to “View data” and select Create Calculated Field…
  2. Rename the Calculated Field to something meaningful. In this case, the calculated field is named “Sex selector”
  3. Enter the formula:
    CASE [Parameters].[Sex]
    WHEN 1 THEN [Male]
    When 2 THEN [Female]
    END
  4. When finished, Click OK.

Step 3: Add the Calculated Field to the view

  1. From the Data pane, drag the calculated field to Color on the Marks card.
  2. Change the colour scheme by clicking the Colour button again and select Edit Colours…
  3. Select different palletes from the drop-down in the Edit Colours dialog box.

Result


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *