KNOWLEDGE BASE

How to Create a Pie Chart Based on the Results of a Logical Function Decision


Published: 03 Jul 2023
Last Modified Date: 05 Jul 2023

Question

How to create a pie chart based on the results of a logical function decision?

For example, suppose you are determining the "High" and "Low" of sales in the following calculated field named Label.

IF SUM([Sales]) >= 10000 THEN "High"
ELSE "Low"
END


In a cross-tab, it works properly.
User-added image

However, it does not work when trying to display the number of customers per Label in a pie chart.
User-added image

Environment

  • Tableau Desktop

Answer

The results of Label calculated field are dynamic depending on the layout of the view. Therefore, to fix the results, we compute using FIXED LOD.
User-added image

1.Create a calculated field and name it Label (FIXED).
IF {FIXED [Customer Name] : SUM([Sales])} >= 10000 THEN "High"
ELSE "Low"
END
2. Open a new worksheet.
3. Change the Mark type to Pie
4. Add Label (Fixed) to Color, and add COUNTD(Customer Name) to Angle.
5. If you'd like to display Percent of Total, right-click COUNTD(Customer Name) in Angle, and add Table Calculation as follows;
 User-added image
Did this article resolve the issue?