How do i change text color based on formula result

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
I have a formula for figuring out how long a task has been opened.

If(([Status]="Completed"),[Date Complete]-[Start],Today()- [Start]))

How do I add to this formula that the number should change color based on days open. For example if the task is open for more then 14 days change to red. 
Photo of frumy horowicz

frumy horowicz

  • 172 Points 100 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of Chris

Chris, Champion

  • 4,390 Points 4k badge 2x thumb

This would no longer be a formula date field but a formula text field. Anything with color, not using script, would be text. Someone else here can probably provide you the jquery or js to do that. But here is out of the box QB using formula text.

If(

([Status]="Completed"),

"<div style='color:#FF0000'>" & [Date Complete]-[Start] & "</div>",

"<div style='color:#0000FF'>" & Today() - [Start] & "<div>"

)


Try this and see if you get the results you want. Notice the single quotes around the color styles. Again, you have to set the data type to formula text and turn on "allow html".

Hope this helps.

(Edited)