Forum Discussion
AnatolyD
Oct 13, 2020Copper Contributor
Conditional Formatting SharePoint List
Hello team, I need your support with conditional JSON formatting of SharePoint list. I would like to format column INVEST_DUE_DATE based on current date (date cell) and based on value in colu...
ganeshsanap
Oct 13, 2020MVP
AnatolyD , Use below condition:
=if((@currentField < @now) && [$PHASE]='Investigation', '#f7adad', if((@currentField <= @now + 864000000) && [$PHASE]='Investigation', '#f2d596', if((@currentField >= @now + 864000000) && [$PHASE]='Investigation' , '#a0dec0', '')))
If you want to apply the background color only if PHASE="Investigation" then you can use below condition as well:
=if([$PHASE]='Investigation', if(@currentField < @now, '#f7adad', if(@currentField <= (@now + 864000000), '#f2d596', if(@currentField >= (@now + 864000000), '#a0dec0', ''))), '')
Please click Mark as Best Response if my post helped you solve your issue. This will help others find the correct solution easily. It also closes the item. If the content was useful in other ways, please consider giving it Like.
AnatolyD
Oct 13, 2020Copper Contributor
Hello!
Sorry, may be I m a little dumb, but
something is still wrong.
I tried both ways
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if([$PHASE]='Investigation', if(@currentField < @now, '#f7adad', if(@currentField <= (@now + 864000000), '#f2d596', if(@currentField >= (@now + 864000000), '#a0dec0', ''))) , '')"
}
}and
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if((@currentField < @now) && [$PHASE]='Investigation', '#f7adad', if((@currentField <= @now + 864000000) && [$PHASE]='Investigation', '#f2d596', if((@currentField >= @now + 864000000) && [$PHASE]='Investigation' , '#a0dec0', '')))"
}
}
PHASE has a single line of text type, not Choice.