Pregunta

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')))"
  }
}
¿Fue útil?

Solución

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'))))"
  }
}
Licenciado bajo: CC-BY-SA con atribución
scroll top