Forum Discussion

Tedster's avatar
Tedster
Copper Contributor
Jun 07, 2022
Solved

Conditional Formatting Help

Hi everyone,

 

Hoping to get help with the following:

 

I would like to set a Dude Date column to change the colour based on how many days to the due date

 

e.g. 3-5 days from due date = white/normal background colour

then 1-2 days from due date = orange

then day of due date = red

 

Also another Due date column for another item

e.g. day of due date = red

then 1-2 days from due date = orange

then 3-7 days from due date = normal/background colour

 

Thank you!

  • Tedster you can do this by formatting the Due column with the following JSON. Note that dates are calculated in milliseconds.

    {
        "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
        "elmType": "div",
        "txtContent": "@currentField",
        "style": {
            "background-color": "=if(@currentField <=@now, '#c00000',  if(@currentField > @now && @currentField <= @now + 172800000, 'orange', 'white'))",
    		"color": "=if(@currentField <=@now+172800000, 'white','#363636')",
    		"padding-left": "5px"
        }
    }

     

     

    Rob
    Los Gallardos
    Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver) 

     

  • RobElliott's avatar
    RobElliott
    Silver Contributor

    Tedster you can do this by formatting the Due column with the following JSON. Note that dates are calculated in milliseconds.

    {
        "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
        "elmType": "div",
        "txtContent": "@currentField",
        "style": {
            "background-color": "=if(@currentField <=@now, '#c00000',  if(@currentField > @now && @currentField <= @now + 172800000, 'orange', 'white'))",
    		"color": "=if(@currentField <=@now+172800000, 'white','#363636')",
    		"padding-left": "5px"
        }
    }

     

     

    Rob
    Los Gallardos
    Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver) 

     

Resources