Forum Discussion
Conditional formatting in lists using JSON condition is between numbers
- Jan 08, 2026
dmann1 you can do this with a shorter json code:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField", "style": { "color": "=if(@currentField <3, 'red', (if(@currentField >= 3 && @currentField <= 5,'orange', 'green'))", "padding-left": "15px", "font-size": "18px", "font-weight": "bold" } }Rob
Los Gallardos
Principal Consultant, Power Platform, WSP Global (and classic 1967 Morris Traveller driver)
dmann1 you can do this with a shorter json code:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if(@currentField <3, 'red', (if(@currentField >= 3 && @currentField <= 5,'orange', 'green'))",
"padding-left": "15px",
"font-size": "18px",
"font-weight": "bold"
}
}
Rob
Los Gallardos
Principal Consultant, Power Platform, WSP Global (and classic 1967 Morris Traveller driver)
- dmann1Jan 09, 2026Copper Contributor
Thanks for the help. It is getting me most of the way there. As your example shows there are three colors. I'll look at your code and try to expand it to five colors to match the five possible answers.
I did lose the formatting I had that had a pill shape coloring and border around the numbers, but I like just the numbers colored too.
- Rob_ElliottJan 10, 2026Silver Contributor
dmann1 you can still have pills using a combination of background-color, border and border-radius as shown below:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField", "style": { "color": "=if(@currentField <0, 'red', if(@currentField >= 0 && @currentField <= 2,'orange', if(@currentField >2 && @currentField <= 5,'white', if(@currentField > 5 && @currentField <= 10,'blue', 'green'))))", "padding-left": "15px", "font-size": "18px", "border-radius": "25px", "background-color": "=if(@currentField <0, 'white', if(@currentField >= 0 && @currentField <= 2,'#483d3b', if(@currentField >2 && @currentField <= 5,'#119cb7', if(@currentField > 5 && @currentField <= 10,'#f5eec9', 'gray'))))", "border": "1px solid #bbb" } }
Rob
Los Gallardos
Principal Consultant, Power Platform, WSP Global (and classic 1967 Morris Traveller driver)