Forum Discussion
misce
Aug 13, 2020Copper Contributor
Conditional Format SharePoint List Due Dates with three conditions - RAG
I've tried searching for this seemingly everywhere and although there's lots of people with similar problems I've not found someone with this exact one and therefore this answer. Apologies if it is a...
- Mar 24, 2021
misce I was recently looking for a similar resource myself. If you are still in need, this code should work for you. If you don't like the exact RAG colors, you can easily replace the them with a different HEX (here is a great site for picking colors: Color Picker Tool - Hex Colors)
{"elmType": "div","txtContent": "@currentField","style": {"background-color": "=if(Number(@currentField) == 0, '', if(@currentField >= @now + 2592000000, '#AFF8C9', if(@currentField >= @now + 86400000, '#EEBB2F', if(@currentField <= @now, '#F06C47',''))))"}}
TKLR_83
Mar 24, 2021Copper Contributor
misce I was recently looking for a similar resource myself. If you are still in need, this code should work for you. If you don't like the exact RAG colors, you can easily replace the them with a different HEX (here is a great site for picking colors: Color Picker Tool - Hex Colors)
{
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(Number(@currentField) == 0, '', if(@currentField >= @now + 2592000000, '#AFF8C9', if(@currentField >= @now + 86400000, '#EEBB2F', if(@currentField <= @now, '#F06C47',''))))"
}
}
Lars_Nolmans_-_Houben
May 17, 2024Copper Contributor
Fine solution, only I would like to have the font white at background #EEBB2F & #F06C47. I do not succeed
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(Number(@currentField) == 0, '', if(@currentField >= @now + 2592000000, '#AFF8C9', if(@currentField >= @now + 86400000, '#EEBB2F', if(@currentField <= @now, '#F06C47',''))))",
"font-weight": "bold",
"padding-left": "15px",
"color": "=if(Number(@currentField) == 0, '',if(@currentField >= @now + 86400000, '#FFFFFF', if(@currentField <= @now, '#FFFFFF',''))"
}
}
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(Number(@currentField) == 0, '', if(@currentField >= @now + 2592000000, '#AFF8C9', if(@currentField >= @now + 86400000, '#EEBB2F', if(@currentField <= @now, '#F06C47',''))))",
"font-weight": "bold",
"padding-left": "15px",
"color": "=if(Number(@currentField) == 0, '',if(@currentField >= @now + 86400000, '#FFFFFF', if(@currentField <= @now, '#FFFFFF',''))"
}
}