KNOWLEDGE BASE

How to color the areas on the pie chart that are over 100% or less than 100% of the target


Published: 15 Mar 2023
Last Modified Date: 16 Mar 2023

Question

How to color the areas on the pie chart that are less than 100% or more than 100% of the achievement

<Example 1>
Achievement is 120%
User-added image

<Example 2>
Achievement is 80%
User-added image

Environment

  • Tableau Desktop

Answer

1. Connect to attached data source 'test.xlsx' from Tableau Desktop.
2. Create a new calculated field as following.
     Name : Over Achievement Area
     Calculation : IF sum([Sales])/sum([Target]) > 1
                          THEN sum([Sales])/sum([Target]) - 1
                          END
3. Create a new calculated field as following.
     Name : Less Achievement Area
     Calculation : IF sum([Sales])/sum([Target]) <= 1
                         THEN 1 - sum([Sales])/sum([Target])
                         END
4. Create a new calculated field as following.
     Name : Achievement Rate
     Calculation : sum([Sales])/sum([Target])
5. Create a new calculated field as following.
     Name : Achievement Area
     Calculation : IF [Achievement Rate] > 1
                         THEN 1-[Over Achievement Area]
                         ELSEIF [Achievement Rate] <= 1
                         THEN 1-[Less Achievement Area]
                         END
6. Create a new parameter as following.
User-added image
7. Create a new calculated field as following.
     Name : Year Filter
     Calculation : [Year]=[Select Year]
8. Change the mark type to Pie.
User-added image
9. Drag [Achievement Area] , [Less Achievement Area] and [Over Achievement Area] to the view.
User-added image
10. Drag [Measure Name] on Rows to Color on Marks.
User-added image
11. Click on Size on Marks -> Adjust size with slider
User-added image
12. Drag [Year Filter] to Filter pane -> Check in 'True'.
User-added image
13. Right click on [Measure Name] on Color -> Sort -> Set as following.
User-added image
14, Right click on [Select Year] -> Show parameter

 
Did this article resolve the issue?