2

I have a Date column in the list and it represents Expiry date.

I need the field to be colored red if the date has passed, orange if the expiry date is less than 30 days, green if the date is more than 30 days.

I have managed to make the formula work, but in the fields where I have no date entered, the field is colored red. I would like to color that field white or not to be colored.

I have tried whit this formula below, but it does not work.

Could someone help me with this please?

{
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "background-color": "=if(@currentField <= @now ,'red', if(@currentField <= @now + 2592000000,'orange',if(@currentField == '','white','green')))"
  }
}
1

You can use Number(DateTimeColumn) == 0 to check if the date column is blank or not.

So try your code like:

{
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "background-color": "=if(Number(@currentField) == 0, '', if(@currentField <= @now ,'red', if(@currentField <= @now + 2592000000,'orange',if(@currentField == '','white','green'))))"
  }
}
3
  • 1
    Where should I add that in the formula? – Djela Jan 31 '20 at 12:35
  • 1
    Check updated answer and try the JSON code – Ganesh Sanap Jan 31 '20 at 12:35
  • Thank you Ganesh, this worked! :) – Djela Jan 31 '20 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.