KNOWLEDGE BASE

How to create dynamic quadrant chart and color background.


Published: 22 Dec 2022
Last Modified Date: 23 Dec 2022

Question

How to create dynamic quadrant chart and color background.

<Desired Behavior>
User-added image

Environment

  • Tableau Desktop

Answer

<STEP 1>
-Combining Data Sources-

1. Connect to Sample Superstore.
2. In Data Source tab, add the attached data source 'Quadrant.xlsx'.
3. Double click on Orders -> Drag Sheet1 of 'Quadrant.xlsx' to palette.
User-added image
4. Select 'Create Join Calculation' from the Data Source pull-down menu. -> Enter '1' .
User-added image
5. Select [Link] from the Sheet 1 pull-down menu. -> Select Full Outer.
User-added image

<STEP 2>
-Create Quadrant chart-

6. Move to Sheet 1 tab.
7. With right clicking , drag [Sales] to Columns -> Select AVG(Sales).
8. Drag [Profit Ratio] to Rows.
9. Drag [Manufacturer] to Detail on Marks.
10. Create a new parameter as following.
User-added image
11. Create a new parameter as following.
User-added image
12. Right click on [Profit Ratio Target] and [Sales Target] -> Show Parameter.
13. Right click on Y-axis (Profit Ratio) -> Add Reference Line -> Set as following.
User-added image
14. Right click on X-axis (Avg.Sales) -> Add Reference Line -> Set as following.
User-added image

<STEP 3>
-Color background-

15. Create a new calculated field as following.
     Name : Max Sales
     Calculation : {MAX({ FIXED [Manufacturer]:AVG([Sales])})}
16. Create a new calculated field as following.
     Name : Min Sales
     Calculation : {MIN({ FIXED [Manufacturer]:AVG([Sales])})}
17. Create a new calculated field as following.
     Name : Max Profit Ratio
     Calculation : {MAX({ FIXED [Manufacturer]:[Profit Ratio]})}
18. Create a new calculated field as following.
     Name : Min Profit Ratio
     Calculation : {MIN({ FIXED [Manufacturer]:[Profit Ratio]})}
19. Create a new calculated field as following.
     Name : X Axis
     Calculation : IF ATTR([Quadrant]) = "Data" THEN AVG([Sales])
                          ELSEIF ATTR([Corner]) = 3 OR ATTR([Corner]) = 4 THEN [Sales Target]
                          ELSEIF ENDSWITH(ATTR([Quadrant]),"Right") THEN ATTR([Max Sales])
                          ELSEIF ENDSWITH(ATTR([Quadrant]),"Left")  THEN ATTR([Min Sales])
                          END
20. Create a new calculated field as following.
     Name : Y Axis
     Calculation : IF ATTR([Quadrant]) = "Data" THEN [Profit Ratio]
                          ELSEIF ATTR([Corner]) = 2 OR ATTR([Corner]) = 3 THEN [Profit Ratio Target]
                          ELSEIF STARTSWITH(ATTR([Quadrant]),"Top") THEN ATTR([Max Profit Ratio])
                          ELSEIF STARTSWITH(ATTR([Quadrant]),"Bottom")  THEN ATTR([Min Profit Ratio])
                          END
21. Drag [X Axis] over [AVG(Sales)] on the Columns shelf.
User-added image
22. Drag [Y Axis] over [AGG (Profit Ratio)] on the Rows shelf.
23. Drag [X Axis] next to [AGG (X Axis)] on the Columns shelf.
User-added image
24. Expand Mark Cards named "AGG (X Axis) (2)" -> Delete [Manufacturer] placed in Labels -> Change the chart type to Polygon.
User-added image
25. Right click on [Corner] on Data pane -> Convert to Dimension.
26. Drag [Corner] to Path on Marks.
User-added image
27. Drag [Quadrant] to Color on Marks.
28. Click on Color on Marks -> Adjust color Opacity.
User-added image
29. Right click on right [AGG (Sales)] on Rows -> Dual Axis.
30. Right click on Y Axis -> Edit Axis -> Delete Axis title.
       *Apply the same procedure to the lower X Axis.
31. Right click on upper X Axis -> Show Header.
       *Header is hidden.
 
Did this article resolve the issue?