SOLVED

Conditional Formatting Help

Copper Contributor

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!

2 Replies
best response confirmed by Tedster (Copper Contributor)
Solution

@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"
    }
}

 

conditionalFormatting.png

 

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

 

1 best response

Accepted Solutions
best response confirmed by Tedster (Copper Contributor)
Solution

@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"
    }
}

 

conditionalFormatting.png

 

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

 

View solution in original post