0

Color Code a Formula

Hello, I would like to color code a formula I have that is subtracting the value from two existing number fields.

 

In this formula, for example named 'Total Demand' I want it to change color based on the values. When the value is a negative number, I would like for it to be red. If it is a positive number, I would like for it to be yellow, and if it =0, then I would just like it to display a gray color.

 

Can someone please help me with this?

12 replies

null
    • SMoore
    • 5 yrs ago
    • Reported - view

    Bump

    • Alexander_Koenig
    • 5 yrs ago
    • Reported - view

    Hi, use the styled() element.

    if demand > 10 then styled(demand,"green")

    else styled(demand,"red")

    • SMoore
    • 5 yrs ago
    • Reported - view

    I am getting an error.

     

    Function is not defined: styled(number,string) at line 2, column 32

    • Alexander_Koenig
    • 5 yrs ago
    • Reported - view

    transform to text:

    styled(text(demand),"red")

    • SMoore
    • 5 yrs ago
    • Reported - view

    Great! Thank you! One last question, how do I specify the exact color code?

    • SMoore
    • 5 yrs ago
    • Reported - view

    I figured it out 

     

    styled(text(demand),color(000,000,000))

    • SMoore
    • 5 yrs ago
    • Reported - view

    Lastly, is there a way to center the text formula, so its not on the left side? 

    • SMoore
    • 5 yrs ago
    • Reported - view

    Bump 

    • Leonid_Semik
    • 5 yrs ago
    • Reported - view

    as a formula feld:

    ---

    html("<center>" + 'Text Field' + "</center>")

    ---

    Leo

    • blackie
    • 5 yrs ago
    • Reported - view

    Is it possible to combine html() and styled() in the same formula?

    • blackie
    • 5 yrs ago
    • Reported - view

    Also, is it possible to create a formula field that uses styled(), and also opens a record with popupRecord() when it is clicked?

    • Birger_H
    • 5 yrs ago
    • Reported - view

    The answer to these last two questions is: Unfortunatly no.

    Birger

Content aside

  • 5 yrs agoLast active
  • 12Replies
  • 5632Views