Forum Discussion
Chris Cundy
Dec 02, 2019Brass Contributor
Column formatting due date?
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?
Hi Chris Cundy,
You can you use a "Calculated" column to store the DueDate value based on the Priority column.
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', '')"
}
}I use the Examples of common formulas in SharePoint Lists site as a reference whenever I created Calculated columns.
I hope this helps.
Norm
Hi Chris Cundy,
You can you use a "Calculated" column to store the DueDate value based on the Priority column.
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', '')"
}
}I use the Examples of common formulas in SharePoint Lists site as a reference whenever I created Calculated columns.
I hope this helps.
Norm