Aug 13 2020 07:44 AM
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 repeated question but I just can't find a straightforward answer anywhere else.
I have a due date column in my Sharepoint list. I want this to highlight the cell in the following ways:
Red if due today or overdue
Amber if it's due within 30 days
Green if due 30+ days away.
Most json codes I find either only have two variables (red or green/overdue or in date) and as far as I can tell the automatic design mode conditional formatting only refers to 'today' rather than 'within a certain number of days to today'.
Does anyone have any code which does the above I can use?
Mar 24 2021 11:40 AM
Solution@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)
Apr 21 2021 05:11 AM
@TKLR_83 Thank you! This worked for me!
Apr 21 2021 05:19 AM
Nov 26 2021 05:54 AM
Feb 13 2024 09:03 AM
@SteCoxy add additional items to the Style section based on your desired CSS
Feb 14 2024 04:36 AM
@SteCoxy You can use font-weight parameter for showing text in bold.
Example:
{
"$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"
}
}
You can also use the similar expression as used for background-color if you want to show the bold text conditionally.
Please consider giving a Like if my post helped you in any way.
Mar 24 2021 11:40 AM
Solution@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)