Conditional Formatting feature is important to gather quick insights on the displayed KPI.
In this blog, we are going to see how to set Conditional Formatting on a KPI number based on a dynamic threshold (comparing against another KPI) in Tableau.
1. As you can see, we have an empty canvas and are going to add Conditional Formatting on “Sales” KPI comparing against last year sales: “Sales LY”.
2. Drag Sales and Sales LY KPIs to Text Mark card.
3. Now, click on Text Mark card and edit the content to get the output as shown below:
4. Let us format the scaling of the numbers for both KPIs by right-clicking on KPIs available in green colour in Marks card and format.
5. In this case, we are going to set the green color for total sales KPI if it is greater than last year otherwise red.
6. We will create 2 calculated fields: ‘sales positive’ and ‘sales negative’.
(Please note, in our example, Sales LY is a calculated field and aggregated already)
7. Please note that only one of them will hold sales value at any given point of time. Drag both fields and place it in ‘Text’ Mark card.
8. As soon as we dragged both the fields, only one of them populated in canvas.
9. Now click on the Text Mark card and change the KPI for sales as shown below:
10.Also, change the color of each KPI according to condition. So, ‘sales negative’ KPI should be in red and ‘sales positive’ in green. I have just increased the font size of both KPIs.
11.Click ok and you should see your ‘Sales’ value in green color.
12. I have formatted the scaling and decimals for both sales negative and sales positive KPI.
Now based on the data updates and value, Conditional Formatting will be taken care and respective colors will be assigned to the KPI accordingly.
To learn more about Visual BI’s Tableau Consulting & End User Training Programs, contact us here.