KNOWLEDGE BASE

Shade Quadrants Created from Intersecting Reference Lines


Published: 03 May 2018
Last Modified Date: 07 May 2018

Question

How to shade sections of a view created by intersection reference lines differently.

Environment

Tableau Desktop

Answer

Option 1: Use a custom background image

See Use Background Images in Your Views for directions. Please note, this option is not dynamic, meaning if the parameter values change, the background will have to be manually adjusted.


Option 2: create a dual axis chart, where one axis is polygon marks to fill the quadrants

This option uses the join calculation feature that was added in Tableau Desktop 10.2.
  1. Join the attached "quadrant scaffolding.xlsx" to the existing data source with a FULL OUTER join. For the linking field, create a join calculation in both the left with the value 1, and use "Dummy Linking Field" from the right table.
  2. Create a calculated field with a name like "x values" with a calculation similar to the following: MIN(
    IF [Quadrant] = "data"
    THEN { FIXED [Customer Name] : SUM([Profit]) }
    ELSEIF [Quadrant] = "lower left"
    OR [Quadrant] = "upper left"
    THEN
        IF [Corner] = 1
        OR [Corner] = 2
        THEN { FIXED : MIN( { FIXED [Customer Name]: SUM([Profit])})}
        ELSE [x-axis parameter]
        END
    ELSE
        IF [Corner] = 1
        OR [Corner] = 2
        THEN { FIXED : MAX( { FIXED [Customer Name]: SUM([Profit])})}
        ELSE [x-axis parameter]
        END
    END
    )
  3. Create a calculated field with a name like "y values" with a calculation similar to the following:

    MIN(
    IF [Quadrant] = "data"
    THEN { FIXED [Customer Name] : SUM([Sales]) }
    ELSEIF [Quadrant] = "lower left"
    OR [Quadrant] = "lower right"
    THEN
        IF [Corner] = 1
        OR [Corner] = 4
        THEN { FIXED : MIN( { FIXED [Customer Name]: SUM([Sales])})}
        ELSE [y-axis parameter]
        END
    ELSE
        IF [Corner] = 1
        OR [Corner] = 4
        THEN { FIXED : MAX( { FIXED [Customer Name]: SUM([Sales])})}
        ELSE [y-axis parameter]
        END   END )
  4. Create a calculated field with a name like "Data Points" with a calculation similar to the following:

    IF [Quadrant] = "data"
    THEN [Customer Name]
    END
  5. Drag [x values] to the Columns shelf
  6. Drag two copies of [y values] to the Rows shelf. This should create two scatter plots, each with a single point, one on top of the other. There will now be three Marks cards: All, AGG(y values), and AGG(y value).
  7. Click on the first copy of AGG(y values) on the Rows shelf to open its corresponding Marks card.
  8. In the dropdown, change the mark type from Automatic to Polygon.
  9. Drag [Quadrant] to Color on the Marks card.
  10. Drag [Corner] to Path on the Marks card.
  11. Click Color and click the Edit Color… button to change the colors as desired.
  12. Click on the second copy of AGG(y values) on the Rows shelf to open its corresponding Marks card
  13. Drag [Data Points] onto Detail.
  14. Right-click the second copy of AGG(y values) on the Rows shelf and check Dual Axis.
  15. Right-click either y-axis in the view and check Synchronize Axis.
  16. Right-click the second copy of AGG(y values) on the Rows shelf and uncheck Show Header.

Additional Information

Notes on Option 2
  • Joining the quadrant scaffolding creates duplicate data, but this duplication is necessary in order to compute dynamic coordinate values for the corners of the quadrants
  • This example starts with a scatter plot created by [Profit] on the x-axis, [Sales] on the y-axis, and [Customer Name] on Detail to create each point. Replace [Profit], [Sales], and [Customer Name] with the corresponding fields.
  • The way that [x values] and [y values] are written assumes that the lower left corner of each quadrant is corner 1, with the numbering continuing counter clockwise. See diagram below.
  • The left most x coordinates (corners 1 and 2 for the upper left and lower left quadrant) should be the smallest value of profit per customer in the entire data set, which is the expression { FIXED : MIN( { FIXED [Customer Name]: SUM([Profit])})}.
    • The inner FIXED statement returns SUM([Profit]) for every unique value of [Customer Name]
    • The outer FIXED statement returns the smallest value of the inner FIXED expression over the entire data set
  • To add buffer to the quadrants, subtract the desired value from the minimum profit per customer in [X values], and add the desired value to the maximum profit per customer
User-added image
To voice your support for the inclusion of this feature request in a future product release, add your vote to the following Community Idea: Reference Line Quadrant Shading
 
Did this article resolve the issue?