5 Replies Latest reply on Aug 8, 2017 2:34 PM by Ben Neville

# Legend stepped color based on a strict rule

Hi !

I'd like to use legend stepped colors to create a strict color code like this:

If the value is negative, the RED, if is between >0 and < 7 , then YELLOW and, finally, if is > 7, then GREEN.

In other words, I want three stepped color but with a strict rule.

Ani idea?

• ###### 1. Re: Legend stepped color based on a strict rule

You just need to use the correct IF THEN syntax for Tableau.

IF [Value] <0 THEN "Red"

ELSEIF [Value] >=0 AND [Value] <= 7 THEN "Yellow"

ELSE "Green"
END

• ###### 2. Re: Legend stepped color based on a strict rule

Hi Ben.

May you explain better with an example?

You may use attached Excel file

• ###### 3. Re: Legend stepped color based on a strict rule

You should just be able to create a calculation in Tableau, paste in my formula, and then drag this new calculation to color. It will create 3 distinct colors for each Red/Yellow/Green result of the calculation - you just need to assign the correct colors to each.

• ###### 4. Re: Legend stepped color based on a strict rule

Hi Ben.

How to force color legend to respect the costraints:

RED, if is between >0 and < 7 , then YELLOW and, finally, if is > 7, then GREEN ?

May you provide me a working example?