Frage

New to this, real Noob.

I have a SP list column named rating, based on the value I need to change the cell color.

  • Value 1 to 3 - Green.
  • Value 4 to 6 - Yellow.
  • Value 8 to 12 - Orange.
  • Value 15 to 25 - Red.

Would someone please be able to help with the code/syntax. Really appreciate the assistance, out of my depth.

War es hilfreich?

Lösung

Try JSON below and modify as needed. In your condition, you have not mentioned the color for the value outside the condition, that is, else condition. I used "gray", but you can change it to your liking.

You can visit MS site for more JSON formatting examples.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "background-color": "=if(@currentField >=1 && @currentField <=3, 'Green', if(@currentField >=4 && @currentField <=6, 'Yellow', if(@currentField >=8 && @currentField <=12, 'Orange', if(@currentField >=15 && @currentField <=25, 'Red', 'gray'))))",
    "color": "black",
    "font-size": "2.0em",
    "justify-content": "center"
  }
}

enter image description here

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top