calculated column for past due item

Copper Contributor

Hello Everyone, 

 

How can I create a calculated column for past due items in a SharePoint list? I have tried this formula, but it isn't working. 

 

=IF([Due Date]>"TODAY","NOT DUE",IF([Due Date]<"TODAY","PAST DUE"))

 

Please assist. 

4 Replies

@suhail_84 you can't use Today in a calculated column. And just adding Today into another column won't work because Today() doesn't update automatically. But there's another solution you might wish to consider which is to color code the Due column depending on if the due date is after today or before today. This is because JSON formatting uses @now and will always evaluate against today's date.

 

Format the column in advanced mode and add the following:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "background-color": "=if(@currentField > @now, 'green', 'red')",
    "color": "white"
  }
}

 

Due.png

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

Thanks, this works ! However, is there any way I can also change the status?

@suhail_84 to display the status you can use JSON advanced column formatting again, although this doesn't save the status to the list it just displays it:

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "=if([$Due] > @now, 'NOT DUE','PAST DUE')"
}

 

A60-status2Column.png

 

If you wanted to save the status to the list itself so you could do other reporting on it then I would recommend building a simple recurrence schedule flow in Power Automate that runs once a day to update the list: if the due date is greater than utcNow() then set the status column to Not Due, otherwise set it to Past Due.

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

IMG_8105.png

@RobElliott when I use your JSON advanced column formatting code above my status column populates all rows with “Past Due.” 

I need the third row to say “Not Due” since that date is still in the future. What am I doing wrong?