SOLVED

Column formatting due date?

Brass Contributor

Hello,

In the below example I am wanting to calculate a DueDate based on the "Priority" column.

So for example if the Priority = "Low" then the Due Date would be "7 days" from "Created" date.

When the list item has hit the DueDate then it should display the text in red.

I am not sure of west way to go about this in SharePoint Modern environment?

helpdesk.png

1 Reply
best response confirmed by Chris Cundy (Brass Contributor)
Solution

Hi @Chris Cundy,

 

You can you use a "Calculated" column to store the DueDate value based on the Priority column.

clipboard_image_0.png

 

Here is my sample code for the Calculated column calculation:

=IF(Priority="Low",Created+7,IF(Priority="Medium",Created+14,IF(Priority="High",Created+21,Created)))

 

Here is my sample JSON code for the column formatting:

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "=if([$DueDate] <= @now, 'ms-fontColor-themePrimary ms-fontWeight-bold', '')"
}
}

 

clipboard_image_1.png

 

I use the Examples of common formulas in SharePoint Lists site as a reference whenever I created Calculated columns.

 

I hope this helps.

 

Norm

1 best response

Accepted Solutions
best response confirmed by Chris Cundy (Brass Contributor)
Solution

Hi @Chris Cundy,

 

You can you use a "Calculated" column to store the DueDate value based on the Priority column.

clipboard_image_0.png

 

Here is my sample code for the Calculated column calculation:

=IF(Priority="Low",Created+7,IF(Priority="Medium",Created+14,IF(Priority="High",Created+21,Created)))

 

Here is my sample JSON code for the column formatting:

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "=if([$DueDate] <= @now, 'ms-fontColor-themePrimary ms-fontWeight-bold', '')"
}
}

 

clipboard_image_1.png

 

I use the Examples of common formulas in SharePoint Lists site as a reference whenever I created Calculated columns.

 

I hope this helps.

 

Norm

View solution in original post