Numeric Formula font color change

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
I have a Numeric Formula. It is a simple subtraction field.
[Total Points 2015-16]-[Total Points 2016-2017] 
I would like to have it turn green when positive, and red when negative. 
I understand you can not do any conditional formatting in a Numeric Formula field. 
I understand you need to use a TextFormal Field. 
I have tried different things i have seen in other post, but i simply can not get it to work at all. 
What formula can i use to make this happen?
Photo of RWest8

RWest8

  • 82 Points 75 badge 2x thumb
  • excited to learn more about QB

Posted 1 year ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,456 Points 50k badge 2x thumb
Try this

// enter your field name here:
var number Rounded = Round([My Points Subtraction field]);

var text MyNumberInText = ToText($Rounded); 


var text ColorCode =
If(
$Rounded < 0,"pink", "green");


Case($ColorCode,
"pink","<div style=\"background-color: pink;\"" & ">" &  $MyNumberInText  & "</div>",

"green","<div style=\"background-color: #00C957;\"" & ">" &  $MyNumberInText & "</div>")
Photo of John Thomas

John Thomas

  • 1,062 Points 1k badge 2x thumb
var number points = [Total Points 2015-16]-[Total Points 2016-2017];

If( $points >= 0 , "<span style=\"color:#008000; font-weight:bold\">"&$points&"</span>", "<span style=\"color:#ff0000; font-weight:bold\">"&$points&"</span>"  )

I hope this will solve the issue !!!
Photo of RWest8

RWest8

  • 82 Points 75 badge 2x thumb
Thanks! Both worked.