Forum Discussion
SharePoint Lists overdue date shade cell
Hi folks,
I'm muddling trough with SharePoint and would love help with something that's been a pain for days!
I have a List for an Issue tracker and a column for "Date reported" what I would love is help with JSON to do the following with that column, in I enter the date reported then if:
Date reported is still within <=5 days the cell is shaded green
If > 5 days but < 10 days its shaded orange
If >= 10 days its shaded red
Thanks
MrDavidGP you can do this with the following JSON:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField", "style": { "background-color": "=if(@currentField < @now && @currentField > addDays(@now, -5), 'teal', if(@currentField <= addDays(@now, -5) && @currentField > addDays(@now, -10), 'orange', if(@currentField <= addDays(@now, -10), 'red', 'white')))", "color": "=if(@currentField <= addDays(@now, -5) && @currentField > addDays(@now, -10), 'black', 'white')", "padding-left": "4px" } }
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)
3 Replies
- MrDavidGPCopper Contributor
HI Rob,
Thanks so much for this as worked a treat and the added white text is a bonus so cheers.
I'm slowly getting to grips with SharePoint and how useful it is. Trial and error and loads of YouTube videos, I'll muddle trough.
Thanks again.
David
- Rob_ElliottSilver Contributor
MrDavidGP you can do this with the following JSON:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField", "style": { "background-color": "=if(@currentField < @now && @currentField > addDays(@now, -5), 'teal', if(@currentField <= addDays(@now, -5) && @currentField > addDays(@now, -10), 'orange', if(@currentField <= addDays(@now, -10), 'red', 'white')))", "color": "=if(@currentField <= addDays(@now, -5) && @currentField > addDays(@now, -10), 'black', 'white')", "padding-left": "4px" } }
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)- MrDavidGPCopper Contributor
Hi Rob,
Thanks so much as that worked a treat, also the white text was a bonus, thanks for doing that as well.
I'm slowly buy mostly trial and error and loads of Youtube (experts in SP) videos.
David