Conditional Format a date column based three other date columns

Andrews, Rob 0 Reputation points
2023-01-25T14:20:54.6833333+00:00

I have a date column (Start Date) that I want to conditionally format based on its relationship to three other date columns (Due Date, Due Date -3mo, Due Date -5mo).

If Start Date is *<*Due Date -5mo, format Green

If Start Date is between Due Date -3mo & Due Date -5mo, format Yellow

If Start Date is > Due Date -3mo, format Red

Basic Conditional Formating options require I pick a static date for the whole Start Date column.

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

1 answer

Sort by: Most helpful
  1. Xyza Xue_MSFT 30,176 Reputation points Microsoft External Staff
    2023-01-31T06:53:01.2833333+00:00

    Hi @Andrews, Rob ,

    You can use this Json code to format the Start Date column.

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
      "elmType": "div",
      "style": {
        "background-color": "=if(Number([$DueDate_x002d_5mo])-Number(@currentField)>0 ,'Green', if((Number(@currentField)-Number([$DueDate_x002d_5mo])>0 && Number([$DueDate_x002d_3mo])-Number(@currentField)>0), 'yellow', 'red'))",
        "color": "black"
      },
      "txtContent": "@currentField"
    }
    

    The running result is as below:

    User's image


    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.

    0 comments No comments

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.