Numeric Formula font color change

  • 0
  • 1
  • Question
  • Updated 2 years 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


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

Posted 2 years ago

  • 0
  • 1
Try this

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

var text MyNumberInText = ToText($Rounded); 

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

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

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

John Thomas

  • 1,082 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


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