top of page
Writer's pictureBernard Kilonzo

Adding Conditional Formatting in Tableau Views

Updated: Sep 4, 2020

Formatting vizzes based on certain conditions (encoded through formulas) allows you guide consumers in data interpretation. This conditional formatting can be encoded through colors, shapes or by simply highlighting the important metrics in the dashboard.

Example 1

In this first example I’ll show you how to apply conditional formatting in a text table.

Using Superstores data set, have created the table below indicating Profit for different product Sub-category’s in different quarters.

Next, have defined how the view will be formatted using the formula below;

(To create the calculated field - Right click anywhere on the dimension or measure area and select Create>>Calculated Field... )

Drag the calculated field ‘Condition formatting’ to the color shelf and format color appropriately.

With this view users can easily spot the profitable Sub-category’s from the rest.

This could also be formatted using shapes in the following;

  • Duplicate the above view

  • Change marks card from Automatic to Shape

  • Hide the labels

  • Drag calculated field ‘Condition formatting’ to the Shape card.

  • Choose the appropriate shape and color

In this case, it's necessary to provide more details through the tooltips in case the user is interested in the actual values.

Example 2

In the second example, I would like to apply conditional formatting to show the States whose Sales is below the average Sales for all States.

  • Create a bar chart using the dimension State and measure Sales

  • Sorting State in descending order by Sum of Sales

  • Add a reference line to show the average Sales for all states.

(To add a reference line, right click on the axis and select Add Reference Line)

Create a calculated field to define how the view will be formatted. (This calculation will format the view in two ways - all States whose Sales is below average Sales for all States will be encoded in the same color, while States with Sales above the average Sales for all States will be encoded in a different color)

Drag the calculated field ‘Condition formatting 2’ to the color shelf.

Format appropriately.

Note, filtering the view doesn't temper with the condition - the condition gets updated as the data and level of view changes. For example, the view below indicates the same view when filtered to Central and East regions'.

I hope this was helpful to you.

To receive more of the Tableau tips and tricks, kindly subscribe to our mailing list.

Thank you.

Blog.png
bottom of page