SharePoint 2013 calculated column formula to change text color based on another column

So I have 2 columns. Column 2 is a choice column (drop down), Column 1 is a single line of text column.

I would the color of column 1 to change based on what is selected in column 2 dropdown soooo..

Column 1     Column 2

Apples          Ripe

Cherries       Not Ripe

Grapes         Ripe

I wrote this in a calculated column called CreateColor

=IF(Column 2="Ripe", 'Column 1=<div style=color:"Green;">', 'Column 1=<div style=color:"Red;">')

Of course it didn't work. Can someone help? I saw a lot of examples that allow you to change the dropdown but not changing another column based on dropdown.


June 30th, 2015 3:08pm

You would need to use SharePoint Designer and add conditional formatting.
Free Windows Admin Tool Kit Click here and download it now
June 30th, 2015 3:49pm

Hi Tink,

To have color coding in the sharepoint list along with the calculated column you have to do few additional CSS/JScript hack, so that the html would recognize the logic.

http://blog.pathtosharepoint.com/2008/12/09/color-coding-more-examples/

http://thinketg.com/creating-a-stoplight-color-coded-status-in-a-sharepoint-list/

Above URL would help you to start with for your scenario.

 

June 30th, 2015 4:42pm

I can't seem to get that to work for me in 2013, maybe because I'm use to using the designer view in 2010 when I do conditional formatting. But I found a solution, I did use designer and create a workflow. Thank you for replying.
Free Windows Admin Tool Kit Click here and download it now
June 30th, 2015 5:43pm

Thank you for your reply but this doesn't help me. I don't want to change the color of a drop down. I want to change the color of one text column (Column 1) based on the drop down selection (Column 2).

I created a 3rd Column, a multi text field, and in designer I used the string builder and it worked.

I wrote:

If Column 2 equals Ripe

  set Column 3 to <div style="color:green;">Column 1</div>

Else

  set Column 3 to <div style="color:red;">Column 1</div>
June 30th, 2015 5:43pm

Your HTML/CSS is wrong:

Create a Calculated Column set the datatype to Number, use the Formula:

    ="<div style=""color:" & IF([Column 2]="Ripe", "Green" , "Red") & ";font-weight:bold;"">" & [Column 1] & "</div>"

Free Windows Admin Tool Kit Click here and download it now
July 11th, 2015 3:53am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics