Forum Discussion
Date Calculations in SharePoint List with conditions
mikehamm35 I forgot to add the screnshot. The calculated column is called Alpha and the formula was =[Expiry]-[Created] and it shows the days between the 2 correctly.
Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)
- KEsiemensAug 23, 2022Copper Contributor
mikehamm35, you have probably figured this out already, but:
- If you want an Alert to occur based on days past, the best way to do that is through Power Automate.
- If you want to change the format of your Alpha column, like red if overdue, yellow if 15 days before overdue, etc., then you can use special JSON code to change colors. In the example below, I have formatted for overdue, soon to be due, past due. The JSON code I used, which I found and modified on one of these extremely helpful forums, is as follows:
{"$schema":"https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json","elmType":"div","attributes":{"class":"= if(Number([$File_x0020_Expires_x0020_On0]) == 0, '' , if([$File_x0020_Expires_x0020_On0] <= @now+86400*15 && [$File_x0020_Expires_x0020_On0] > @now , 'sp-field-severity--warning', if([$File_x0020_Expires_x0020_On0] <= @now, 'sp-field-severity--blocked', if([$File_x0020_Expires_x0020_On0] > @now+86400*75, 'sp-field-severity--good', 'sp-field-severity--good') ) ))"},"children":[{"elmType":"span","style":{"display":"inline-block","padding":"0 4px"},"attributes":{}},{"elmType":"span","txtContent":"@currentField"}]}
This code would go in the Column Formatting field of your calculated column. This is done in SharePoint.
For sending alerts to people who own the past due content, use a Power Automate flow which looks something like this.
You would change the Get File (properties only) step to Get Items.
- RobElliottFeb 25, 2022Silver ContributorBut if it's a modern list InfoPath isn't supported.