Forum Discussion
Missile64
Nov 21, 2022Copper Contributor
Change border colour of Text field based on Date Field - Calculated Field
I have a SharePoint list that contains a list of documents that require periodic reviews. I would like to have a Calculated field that adds a red border on the Title field when the Next Review Date field is < Today, and Amber if the Review Date field is within 1 Month from Today.
JS is not allowed hence the need for a Calculated field.
Title - Text Field | Next Review Date - Date Field | Todays Date 22-11-2022 |
Document 1 | 25-10-2022 | Red border because it is past Review Date |
Document 2 | 12-12-2022 | Amber border because it is within 1 month of Review Date |
Document 3 | 20-02-2023 | Nothing as it is over 1 month from Review Date |
Document 4 | 21-11-2022 | Red border because it is past Review Date |
Thanks in advance
Pete
Missile64 If you are using modern experience in SharePoint online, you can use JSON column formatting for your title column like:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "style": { "padding-left": "5px", "border": "2px solid", "border-color": "=if([$NextReviewDate] < @now, 'red', if([$NextReviewDate] >= @now && [$NextReviewDate] <= addDays(@now, 30), 'orange', ''))" }, "children": [ { "elmType": "span", "txtContent": "@currentField", "style": { "color": "black" } } ] }
Output:
Where NextReviewDate is the internal name of your date column. Follow this article to get the internal name of your SharePoint column: How to find the Internal name of columns in SharePoint Online?
Documentation: SharePoint column-formatting
Please click Mark as Best Response & Like if my post helped you to solve 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.
For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs