Tableau Desktop Quick Tip: Conditionally Format Tableau Visuals
We want to create decent business insights with little effort in business intelligence. Automation is a crucial part to reduce the effort in analyzing business insights. In this article, we would leverage data visualization tools Tableau Desktop to help us create a visual that automatically updates its value.
CheeChuan Foo
We want to create decent business insights with little effort in business intelligence. Automation is a crucial part to reduce the effort in analyzing business insights. In this article, we would leverage data visualization tools Tableau Desktop to help us create a visual that automatically updates its value.

Table of Content
Problem Statement
Imagine you own a retail store that has multiple product categories. We would like to create a chart to monitor the performance of each product subcategory. To achieve this, we would create a bar chart that changes color, green if hits target; red if otherwise. We would also want to show a “*” icon on top of each bar and it would also change its color according to the stated condition. Without further ado, let’s get started with the tutorial.
A bar chart with a reference line
First, add a reference line to your bar chart.

Follow the settings below to create a reference line.

Note that we add a <value> parameter to the reference line label. So that when we change the value the label would change itself.
Next, let’s format the label to the center of the view.


Color bar conditionally
We can achieve this by creating a simple if…else function.


Then drag this field into the Color card.

Now we have a bar chart that changes color with the condition we specified. Now let’s change the color to what we wanted.

Note that you need to select the category before choosing a color.

Adding “*” to the bars
The trick for adding a bar is the Label. Yes, the star is a string that we show through the label. But first, you need to create a calculated field.
Remember that [Meet Target] will return “True” when the subcategory meets the sales target so this field is automatically boolean.

The “*” is copied from this website. I chose a star, but you can always pick the one you prefer.

Also, note that you need to enclose your icon in “ “ so that Tableau knows it’s a string.
Then we’ll drag the field into the label.


Wait… why didn’t the star at the bottom show up?
Conditionally format label
I did it on purpose. We need another label for those who didn’t meet the sales target.


But why create 2 calculated fields? We did this so that we can color the stars in a different colors. Now let’s edit the label to format the stars.


Note that the labels are stacking vertically. We want to place them side-by-side instead.

This is very important because as your font size becomes larger, the star at the bottom would not show because the blue star although didn’t appear occupies space even if it’s a null value.
Final Outcome

There we go, an easy tutorial to conditionally format your visual. Please share this article with your friends if you think it would help them improve their skills.
Also, check out my Youtube video if you’d like to have a video tutorial.
Video Tutorial
Till the next one, see you again!
Upvote
CheeChuan Foo
Technical Writer| Content Creator| Freelancer

Related Articles