Forum Discussion
SP Online List Formatting Cell Colour
I have a simple list that contains column months and totals. See below:
If any cell is greater than £0 I would like to change the background colour of that cell to red.
How can I achieve this?
Bharath Arja Thanks.
So, it's not possible to apply this styling to a complete list? If I have 50 columns I need to do this 50 times, manually?
7 Replies
jonboylib Try using below JSON, it should work for number columns:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "style": { "background-color": "=if(@currentField > 0, 'red', '')", "color": "white" }, "txtContent": "@currentField" }
This JSON adds background color of cell as red. You can change the style as per your requirements.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- jonboylibIron Contributor
ganeshsanap Thanks, where do I add this JSON?
Also, I assume I don't have to add this to every row in my list?
- Bharath ArjaIron ContributorYou add the JSON to columns where you want this formatting. Select the drop down next to column -> Column settings -> format this column -> Select Advanced mode -> Paste the JSON ganeshsanap provided. Do this for each column you want to add formatting to.