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 less and also apply a different color if the number is between 3 and 5. I've tried replacing the "1" above with "=IF (<=2)" and "=IF(@currentField <=2)" with no luck. Thanks
1 Reply
- Rob_ElliottSilver 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)