5 Replies Latest reply on Dec 27, 2013 4:56 PM by Ramon Martinez

# Apply color based on logic

Hello!

I have a workbook with data extract and what i'm trying to do is apply color to the column cells based on it's logic.

I have also attached an excel as an sample and the color applied to the excel cells are what excatly i want to do in tableau.

Highlighted column in excel are being used in workbook.

here's the logic to use the color:

 Color % Text Red less than 90 <>approved Functional specification<> accepted FCC status<>reviewed unit test plan yellow 90-100 n/a green 100 approved Functional specification accepted FCC statusreviewed unit test plan

Above is the color i want to apply to those two feilds(% and text) for those resp values.

PS: the "%" column/dimensions have "string" data type in workbook.

I'm very new to tableau and any help is appreciated.

Thank you

rita

• ###### 1. Re: Apply color based on logic

Not sure by your above specs what the exact question is but if your color requirement is strictly based off of a single cell value then the equation would be something like:

If [Test Passed Percentage] =1 then 'green'

elseif [Test Passed Percentage] >= .9 then 'yellow'

else 'red'

end

If the values need to be aggregate calcs like an average then the calc would need to account for that as well

Not sure how "green" you are with Tableau so if you need any further explanation let me know.

If the above logic doesn't match what the requirement is let me know.

Regards

• ###### 2. Re: Apply color based on logic

Hi Aaron,

Based on this logic for % column I need to apply color in the worbook. for example,

if[Test Passed Percentage] = 100 then 'green'

elseif [Test Passed Percentage] <90 then 'red'

elseif [Test Passed Percentage] >90 and [Test Passed Percentage] <100 then 'yellow'

end

the data type for Test Passed Percentage is 'String' and then I changed it to 'INT' so that above logic can be used.

The above logic is valid and then I placed the calculated field in a color shelf and change the color. But i'm not able to see colors applied to the cells in the workbook.

Is there anything i'm doing wrong or missing. How do i apply color based on above logic?

Thanks,

Rita

• ###### 3. Re: Re: Apply color based on logic

Hello Rita,

The logic for the calculated field should be:

```IF [Tests Executed Percentage]<.9 THEN 'red'
ELSEIF [Tests Executed Percentage]<1 THEN 'orange'
ELSE 'green' END
```

I attached a workbook based on your data that includes three different alternatives. Please, take a look at it to see if it helps to solve your requirements.

Best regards,

Ramon

• ###### 4. Re: Apply color based on logic

Hi Ramon,

I'm using tableau 7.1, could you please send me the workbook created in 7.

Thanks,

rita

• ###### 5. Re: Apply color based on logic

Ouch!!

I don't have version 7.1 with me now.

Let me see what I can do.

Ramon