Forum Discussion

DavidSemitekol's avatar
DavidSemitekol
Qrew Trainee
2 years ago
Solved

Color-coding a field returns field name

I have a purchase date field and a second field that is calculating the age based on Today's date.  In a third field I have a rich text field that I'm trying to color-code red if the age is greater than 3 years.  If not, I want to just return the age.  I'm able to return the age but the color is only returning the field name, not the actual value.

Here is the Age Formula:
var date DOB = [Purchase Date];

var number Years =

Year(Today())-Year($DOB)
-
If(
Month(Today())<Month($DOB)
or
(Month(Today())=Month($DOB) and Day(Today())<Day($DOB)),1,0);

var number MonthsDifference = Month(Today()) - Month($DOB) ;
var number Months = If($MonthsDifference >= 0, $MonthsDifference, 12 + $MonthsDifference);

Round($Years + $Months/12,0.1)

Here is the formula to apply the color:
If([Age Formula]>3,"<div style=\"background-color:red;\">[Age Formula]</div>",ToText([Age Formula]))

Here is the report example:


------------------------------
David Semitekol
------------------------------
  • Use below formula to apply color :

    If([Age Formula]>3,"<div style=\"background-color:red;\">"&[Age Formula]&"</div>",ToText([Age Formula]))


    ------------------------------
    Pranav Choudhary
    Quickbase Expert Builder Certified by Quickbase
    beniwalpranav@gmail.com
    ------------------------------

2 Replies

  • Use below formula to apply color :

    If([Age Formula]>3,"<div style=\"background-color:red;\">"&[Age Formula]&"</div>",ToText([Age Formula]))


    ------------------------------
    Pranav Choudhary
    Quickbase Expert Builder Certified by Quickbase
    beniwalpranav@gmail.com
    ------------------------------
    • DavidSemitekol's avatar
      DavidSemitekol
      Qrew Trainee
      Thanks, adding the "& [Field] &" worked perfectly.

      ------------------------------
      David Semitekol
      ------------------------------