Let end users change the color palette in Tableau with a parameter

Brittany Rosenau
4 min readAug 25, 2022

--

Image of a dashboard in Tableau

You may find yourself in a situation where a stakeholder would like to see information colored in different ways. Rather than creating multiple charts, one way to do this is let them select different categorical colors by using a parameter.

In this example, we will use a bar graph showing total Profit, Quantity, and Sales from the Superstore dataset.

Step 1: Create Parameter

Create a parameter by using the dropdown near the top of the Data pane, or right clicking in the data pane and clicking “Create Parameter”.

Create Parameter

In the dialogue box that opens,

  • Give your parameter a name
  • Select Data Type: String
  • Select Allowable Values: List
  • Type in the fields you want to color by in the list of values.
  • Click “OK”

Note: In this case, ‘Default’ is not a field but will be one of the options we use to color by later.

Create Parameter Dialogue Window

Step 2: Create a calculated field to use for the Default setting.

This step is optional, but since I am using it in the example we’re going to create it! Create a calculated field by clicking on the down arrow near the top of the data pane, or right clicking in the data pane and selecting Create Calculated Field.

Create Calculated Field

In this case, I just want the default color to be solid based, so I enter the string ‘color’. Click OK.

Create default color field

Step 3: Create a Calculated field to color by

Use a CASE statement to determine what fields to color by. After WHEN you should list the string values that you typed in the parameter we created in step 1. After the THEN, enter the field that you want to color by when the user selects the option. You can see in this case, when the user selects ‘Default’, the field we created in step 2 is used. Click OK.

Create Color By Case Statement field

Step 4. Show the parameter on the view

Right click the parameter created in step 1, and click Show Parameter.

Show Parameter

You’ll notice that the Color By Selector now shows up on the right.

Color by selector in interface

Step 5. Set your Colors

Drag your ‘Color By’ calculated field onto Color on the Marks shelf

Drag Color By field to Color

Time to change the default color!

  • Click Color
  • Click Edit Colors
  • Choose what color you’d like for ‘color’ (or whatever string you entered for your calculated field in step 2)
  • Click OK
Edit Colors

Now, in your Color by Selector, select Category instead of Default. You’ll notice the bars are now colored by category.

Change your selection

If you’d like to change the automatic colors applied, repeat the process of clicking Color > Edit Colors, choosing your colors, and clicking OK.

Edit colors again!

Repeat the process one last time by selecting Segment, and choosing your colors.

Change your selection

Step 6: Creating your dashboard

On your dashboard, you now need to make sure your parameter is visible for your end users.

  • Select your sheet on the dashboard
  • Click the little down carrot (▼)
  • Click Parameters
  • Click Color by Selector
Show Parameter on Dashboard

That’s it! Now your users can select how they’d like your chart to be colored.

Bonus Step

You can make the user’s selection visible in your chart title as well. When editing the title, insert the parameter as shown below:

Add parameter selection to title

Your title will look something like this:

Title dialogue window

Now, when your user selects what to color by, it will appear in the title. This can be handy if your selector is not near the chart, or is hidden in a show/hide container.

Example showing title changed based on parameter selection

I hope this was helpful! Note — colors and chart used in this example is for illustrative purposes. Please make sure to follow best practices when chart choosing as well as picking colors.

You can check out the interactive dashboard, and download for yourself to reverse engineer here: Tableau Public Link

Happy vizzing!

--

--

Brittany Rosenau

Design Nerd | Analytics Professional | 6x Tableau #VizOfTheDay | Iron Viz Finalist | Tableau Visionary + Public Ambassador