Pregunta

I want the columns with no value in it to be blank. What should I add to my formula?

annotated screenshot illustrating the desired outcome

{   
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "debugMode": true,
  "txtContent": "@currentField",
  "attributes": {
    "class": "=if([$Sovtid_x0020_tekniker_x0020_2] <= @now, 'sp-css-backgroundColor-successBackground50', 'sp-css-backgroundColor-blockingBackground50')"
  }
}
¿Fue útil?

Solución

Try using your JSON code something like below:

{   
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "debugMode": true,
    "txtContent": "@currentField",
    "attributes": {
        "class": "=if(Number(@currentField) != 0, if([$Sovtid_x0020_tekniker_x0020_2] <= @now, 'sp-css-backgroundColor-successBackground50', 'sp-css-backgroundColor-blockingBackground50'), '')"
    }
}

Note:

You can use Number(DateTimeColumn) == 0 to check if the date column is blank or not. This is the major hint, rest you can build the JSON code around it according to your other conditions.

References: Use column formatting to customize SharePoint.

Licenciado bajo: CC-BY-SA con atribución
scroll top