0

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.

0

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

1
  • Hi Matiur, Thank you!!!!! That is perfect, exactly what I was after. Really appreciate the help. – Keith Oct 4 '20 at 21:45

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.