Conditional formatting of SharePoint List Column

Paul Spurr 0 Reputation points
2023-01-13T13:48:31.9133333+00:00

I have a SharePoint custom list with multiple date columns. I want to format the date in a column (Pt1 Returned) to display red text when that date exceed the value of another (date) column (48hr Deadline). Simple conditional format only allows the condition to be today or a specific (selected) date.

Put simply, if Pt1 Returned is greater than 48hr deadline, the value of Pt1 Returned is highlighted red.

Can JSON code be used to create the format, if so, I've not used JSON before so would be grateful to anyone who can suggest code to make this work.

Thanks

Microsoft 365 and Office SharePoint Development
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Renjie Sun-MSFT 2,861 Reputation points Microsoft Employee
    2023-01-16T02:58:06.5633333+00:00

    Hi Paul Spurr

    Thanks for the post.

    You could refer to the following code template:

    • Using column formatting in 'Date' column. (Pt1)
    • If the 'Date' value is greater than 'deadline' Date + 48 hours, the character turns red.

    {

    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",

    "elmType": "div",

    "debugMode": true,

    "txtContent": "@currentField",

    "style": {

    "color": "=if(@currentField>=([$deadline]+(1000*60*60*48)), '#ff0000', ' ')"

    }

    }

    Testingresult:

    User's image

    I hope I can offer you a better experience next time if I have a chance to work with you again.

    Yours faithfully,

    Renjie Sun


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Paul Spurr 0 Reputation points
    2023-01-17T16:01:43.6633333+00:00

    Thanks for providing an answer, unfortunately it is not working, but I think that is my fault.

    My original post didn't include the actual name of the 'deadline' column and I don't know where to find how it should appear. The actual heading of the column is 48hr Part 1 Deadline.

    Can you please advise how this should appear in the coding =([$?????]

    User's image

    User's image


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.