Conditional Formatting in Tableau – How to Apply

When I was building a sales report in Tableau, I wanted to highlight the top-performing products in green and the low-performing ones in red. At first, I thought I had to create a calculation, but then I got the expected output using the conditional formatting in Tableau.

In Tableau, conditional formatting allows us to highlight values, apply custom colors, or use icons based on specific conditions. This makes Tableau charts more interactive and easier to read.

In this tutorial, I will explain how to apply conditional formatting in Tableau charts using examples.

Conditional Formatting in Tableau

In Tableau, there are three methods through which we can apply conditional formatting in Tableau charts.

  • Conditional formatting in Tableau using color shelf
  • Conditional formatting in Tableau using highlight tables
  • Conditional formatting in Tableau using a dual-axis chart

In the examples that follow, we will discuss how to apply conditional formatting in Tableau using the Tableau Superstore data set.

Conditional Formatting in Tableau Using Color Shelf

To apply conditional formatting in a Tableau chart, the simplest method is to use the color shelf.

In this chart, we will show the sales across different product subcategories, and in the condition, we will display the bars with sales less than 150k in red and more than that in green.

Now, connect the Tableau with the Superstore data set and follow the steps below to apply conditional formatting in Tableau using the color shelf.

  1. To create the chart view, add the Subcategory to the Rows and Sales to the Columns. With this, we will get a bar chart on the sheet.
Conditional Formatting in Tableau
  1. For color formatting, either add ‘profit‘ or ‘sales‘ to the color card.
Tableau Chart Custom Formatting
  1. To apply the conditional formatting, click on the color card and select Edit Colors.
  1. In the Edit window, select a diverging color such as the Red-Green diverging color. For conditional formatting, enter custom values for Start as 0, Center as 150000, and End as the last range, or keep it default.
Tableau Bar chart conditional formatting

Now, according to the conditional color formatting, we will see that bars with sales less than 150k are in red, and bars with sales more than 150k are in green.

Conditional formatting in Tableau charts

This way, we can apply conditional formatting in Tableau using the color shelf.

Conditional Formatting in Tableau Using Highlight Tables

When displaying data in a table format instead of bars, using highlight tables is the ideal way to show conditional formatting.

In this example, we will highlight the sales profits using the formatting in the highlight table.

  1. Drag the Category to Rows and Region to Columns. After this, drag Sales to Text in the Marks section.
  1. From the “Show me” tab, choose “Highlight Table.”
Conditional formatting in tableau using highlight table
  1. Now drag the Profit to the Color. This will shade each cell based on profit values.
Tableau conditional formatting
  1. For the formatting, we can also select a different color gradient, such as ” diverging red green” that will show profit in green shades and loss in red.
Color formatting in tableau using highlight table

With this, we will see the loss or lower profit in red color shades and the profit values in green color shades.

Add conditional formatting in Tableau chart

This way, we can apply conditional formatting in Tableau using the Highlight tables.

Conditional formatting in Tableau Using a Dual-Axis Chart

Another method through which we can apply conditional formatting in Tableau is using the Dual-Axis chart.

In this chart, we will display the profit in product subcategories.

  1. Drag the dimension Sub-category to the Rows.
  1. After this, go to Columns and enter “1” to create an average measure.
dual axis chart for conditional formatting in tableau
  1. By default, the measure will be in sum, so click on it and select a Measure(sum) -> Average.
Tableau dual axis chart conditional formatting
  1. Now, add the avg(1) again to the Columns to create the duplicate chart.
  1. Click on the second axis and select Dual-axis.
Conditional formatting In Tableau bar chart
  1. Now, right-click on the axis and select Edit Axis. In the edit window, select Synchronize dual axes. In the Axis titles, enter the custom title as Profit. Repeat the same on the second axis.
Add conditional formatting in Tableau
  1. In the All Marks section, select the type as Bar.
Tableau chart with conditional formatting
  1. Drag the Profit to the color card in the All Marks section.
Add Color using conditional formatting in Tableau
  1. To set only two colors, such as red and green, instead of shades, click on Edit Colors in the color card.

In the Edit color window, select the diverging red-green color. Then select the checkbox, stepped color, and enter 2.

Use color for conditional formatting in Tableau

With this, we will get the profit values in red for bars with less profit and in green for higher profit. This color range is also decided in the Edit color window, where we can customize the start and end.

Use conditional formatting in Tableau

This way, we can apply conditional formatting in Tableau using the dual-axis chart.

Conclusion

In this Tableau tutorial, we have learned three different ways to apply conditional formatting in Tableau: using the Color Shelf, Highlight Tables, and Dual-Axis Charts.

According to requirements, we can use the Color Shelf method for simple bar charts, Highlight Tables for tabular comparisons, and the Dual-Axis approach to format measures separately.

You may also like to read:

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.

Salesforce flows complete guide

FREE SALESFORCE FLOW EBOOK

Learn how to work with flows in Salesforce with 5 different real time examples.