SharePoint List-Custom Conditional Formatting for "Modified" Column

Harry N Nomikos 1,336 Reputation points
2021-09-06T03:05:11.99+00:00

Hi Team

I was wondering if you could please help with how I can apply Conditional Formatting for the "Modified" column on a SharePoint list under the Modern view.

I'd like it to reflect the below conditions;

If a list entry hasn't been modified in the last 2 weeks from today>highlight orange
If a list entry hasn't been modified in the last month from today> highlight red

I'm very limited with the type of access I have, so JSON formula would be best or if it can be done with the current conditional format fields in some way, that'd be great :)

Cheers,
Harry

Microsoft 365 and Office SharePoint Development
Microsoft 365 and Office SharePoint For business Windows
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2021-09-06T09:28:57.31+00:00

    Hi @Harry N Nomikos ,
    Since we need to use JSON formula, column formatting is our best choice.
    Please refer to the following code and link:

    {  
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",  
      "elmType": "div",  
      "debugMode": true,  
      "txtContent": "@currentField",  
      "style": {  
        "background-color": "=if(floor((Number(@now)-Number([$Modified]))/(1000*60*60*24)) >= -1 && floor((Number(@now)-Number([$Modified]))/(1000*60*60*24)) < 30, '#ffbf00', if(floor((Number(@now)-Number([$Modified]))/(1000*60*60*24)) >= 30, '#ff0000', '')"  
     }  
    }  
    

    https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.