Format Column in Lists based off of Dates in the Column and another Column

Ramirez, Nicholas 1 Reputation point
2021-05-07T20:29:40.127+00:00

Hello,

I want to create a completion date column in my Sharepoint list that turns red if the date in it is past the due date. Here is what I have:

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "=if([$Completion_x0020_Date] >= [$Due_x0020_Date],'sp-field-severity--severeWarning', '')"
}
}

This code does simply turns every entry red. Has someone encountered this before?

Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Echo Du_MSFT 17,316 Reputation points
    2021-05-10T05:45:35.187+00:00

    Hello @Ramirez, Nicholas ,

    Welcome to Q&A Forum!

    Please check your columns' DisplayName:
    List Settings>> scroll to Columns section >> click on the specific columns

    95119-column-displayname.png

    Here is Column Format:

    {  
    "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",  
    "elmType": "div",  
    "txtContent": "@currentField",  
    "attributes": {  
    "class": "=if([$DueDate] <= [$CompletionDate], 'sp-field-severity--severeWarning', '')"  
    }  
    }  
    

    95076-column-format.png

    Thanks,
    Echo Du

    ======================

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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.


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.