0

Change colour of a formula box if it’s a year later

I have a Last Updated date box and a formula box called Last updated status, I basically want to make it so after a year from the date in the last updated box the formula for the status turns red.

TIA

10 replies

null
    • Nick
    • 3 yrs ago
    • Reported - view

    Try this in the formula box called Last updated status:

     

    let t := days('Last Updated', today());
    styled("Status", if t > 365 then "red" end)

    • yewani
    • 3 yrs ago
    • Reported - view

    It shows up as status in the box, but it doesn't change colour when more than 365 days

    • yewani
    • 3 yrs ago
    • Reported - view

    Nevermind it's sorted! Nice one Nick :)

    • yewani
    • 3 yrs ago
    • Reported - view

    Als what would I add to it to make it green when it is under 365 days? I've just tried with the same sort of code but it's not working for me.

    TIA

    • Nick
    • 3 yrs ago
    • Reported - view

    Sure,

    ---

    let t := days('Last Updated', today());
    if t > 365 then
    styled("Expired", "red")
    else
    if t < 365 then
    styled("Not Expired", "green")
    end
    end

    ---

    Change the words "Expired" and "Not Expired" to suit your needs

    • John_Halls
    • 3 yrs ago
    • Reported - view

    Hi Nick

     

    I hope you don't mind but I would just have

     

    let t := days('Last Updated', today());
    if t > 365 then
    styled("Expired", "red")
    else
    styled("Not Expired", "green")
    end

     

    Regards John

    • yewani
    • 3 yrs ago
    • Reported - view

    Thank you both :)

    • Nick
    • 3 yrs ago
    • Reported - view

    You're right John, I just wanted to show him the case of multiple ifs...

    • Mel_Charles
    • 3 yrs ago
    • Reported - view

    John/Nick

    Both methods work and that is good what you have shown yewani is that there are several ways to achieve the required result - even better !!
    In fact, a somewhat wise tutor once told me that when starting out with coding that was better to code it as you are saying it and have the multiple if's etc as it makes it initially easier to follow in your head. Once comfortable with what you are doing then you can go back and refine the code. I think he referred to it as spaghetti code back then cos we often resorted to jumping all over the place! Certainly made for some long coded scripts! before we embarked on proper sub routines etc. :-)

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    That's beautifully put, as ever Mel 👍

Content aside

  • 3 yrs agoLast active
  • 10Replies
  • 507Views