KNOWLEDGE BASE

Conditionally Color Data Based On The Result Of The Trend Line


Published: 22 Jun 2020
Last Modified Date: 22 Jun 2020

Question

How to conditionally color the marks based on the trend line?
e.g. color the points above the trend line.

Environment

  • Tableau Desktop

Answer

1. Hover the mouse over the trend line to confirm the equation.
User-added image
2. Create a calculation field Trend line, based on the equation above.
58.5669*sum([Quantity])+99.7412
3. Create a calculation field Above Trend line?
SUM([Sales])>[Trend line]
4. Add Above Trend line? to Color, now the color of the plots will be separated in 2, but there will be 2 trend lines
5. Right click one of the trend lines and select Edit Trend Lines...
6. Uncheck the following factor AGG(Above Trend line?) from the Options
User-added image

7. Change the color of Above Trend line?
Did this article resolve the issue?