Can I make a negative number red in a Text Display Object


#1

In a form, I have a Net profit or loss field displayed in a TDO whose value is set in the Formula panel with this code:

?(«Nett receipts» > 0 and «Nett cost» > 0,
    pattern(«Nett receipts» - «Nett cost»,"$#,"),
zeroblank(0))

I would like to have negative values (losses) displayed in red but I can’t see how to do it. I can always fall back on parentheses but red really jumps out at the viewer. is it possible?


#2

Michael, here is a simplified example of the formula for a TDO that displays negative numbers in red. I have an integer field named “Numbers”. (I assume you have checked the Rich Text option for that Text Display object.)

?(Numbers<0,"<color:FF0000>"+str(Numbers)+"</color>",str(Numbers))

#3

Kurt beat me to the punch in suggesting Rich Text.

If the number is the only text being displayed in the text object you don’t need the closing </color> tag, so the formula can be a bit simpler:

?(Numbers<0,"<color:FF0000>","")+str(Numbers)

#4

That’s what I’d missed - thanks guys.