1

I am using a conditional format for the cells but I want that the empty cells keeps the default color, but with my conditional format the cells with no information are in red color.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "color": "=if(@currentField <= @now, 'black',if(@currentField <= @now + 7776000000 && @currentField > @now,'black','black'))",
    "font-weight": "=if(@currentField <= @now, 'bold',if(@currentField <= @now + 7776000000 && @currentField > @now,'semi-bold','normal'))",
    "background-color": "=if(@currentField <= @now, 'red',if(@currentField <= @now + 7776000000 && @currentField > @now,'orange','green'))",
    "padding-left": "14px"
  }

1 Answer 1

0

In JSON Formatting, you can check if Date & Time column is blank like:

Number(@currentField) == 0

You can find other ways to check if date & time column is empty or not at: SharePoint JSON formatting: Check if date & time column is blank/empty

GitHub sample for reference: Formatting a column when a date column is blank


For your scenario, try using this JSON:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "@currentField",
    "style": {
        "color": "=if(Number(@currentField) == 0, '', if(@currentField <= @now, 'black',if(@currentField <= @now + 7776000000 && @currentField > @now,'black','black')))",
        "font-weight": "=if(Number(@currentField) == 0, '', if(@currentField <= @now, 'bold',if(@currentField <= @now + 7776000000 && @currentField > @now,'semi-bold','normal')))",
        "background-color": "=if(Number(@currentField) == 0, '', if(@currentField <= @now, 'red',if(@currentField <= @now + 7776000000 && @currentField > @now,'orange','green')))",
        "padding-left": "14px"
    }
}
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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