Conditional Formatting

Copper Contributor

Hey!

 

I'm have two columns on my sharepoint list (date the survey was sent) + (Installation start date).  I'd like highlight the installation start date red if the date the survey was sent was within 7 days.  Is there a JSON code I can use for this?

2 Replies

@johncamp08 

 

This example should get you started. The key is the formula shown on line 8 which uses the if function to turn on special classes if the comparison returns true.

{
    "elmType": "div",
    "children": [
        {
            "elmType": "span",
            "txtContent": "@currentField",
            "attributes": {
                "class": "=if(addDays([$SurveyDate],6) < [$InstallDate],'sp-css-color-RedText sp-field-bold','')"
            }
        }
    ]
}

 

To learn more: https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/formatting-syntax-referenc... 

 

Good Luck,

Don 

 

Please click Mark as Best Response & Like if my post helped you to answer or resolve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

On the Home tab, in the Style group, click the arrow next to Conditional Formatting, and then click Highlight Cells Rules. Select the command you want, such as Between, Equal To Text that Contains, or A Date Occurring. Enter the values you want to use, and then select a format. If your problem is solved then tell me. Now I am going to bookmark this here https://techcommunity.microsoft.com/t5/sharepoint/conditional-formatting/td-p/3050075-results.