Forum Discussion
dmann1
Jan 06, 2026Copper Contributor
Conditional formatting in lists using JSON condition is between numbers
I'm trying to use JSON to conditional format a color based on the number in the cell. This code works if the number is one in the cell. I would like to apply the same color if the number is 2 or...
- 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)
Rob_Elliott
Jan 08, 2026Silver Contributor
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.