Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MarkHughes
Regular Visitor

Calculating over 30 , 60 and 90 days and output to column

Hello,

 

Data Source: SharePoint Online list

Developing in: PowerBI Desktop

 

I have a query about a query that I'm hoping some kind member of the community can help me with,

 

Issue

I need to have 3 count panels on my report to show a count of items that are overdue for 30, 60 & 90 days. The Column name is "Date Due" and I also have an "Overdue" column. I need assistance creating a calculation to look at the "Date Due" column and if it's 30, 60 or 90 days have passed from todays date, it must input either 30, 60 or 90 into the Overdue column based on the result.

 

Much appreciated

1 ACCEPTED SOLUTION

I assumed the [Due Date] is of type Date, while it's actually DateTime
this should work

if Duration.Days(DateTime.LocalNow() - [Date Due])>=90 then 90 else 
if Duration.Days(DateTime.LocalNow() - [Date Due])>=60 then 60 else 
if Duration.Days(DateTime.LocalNow() - [Date Due])>=30 then 30 else 
0

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

5 REPLIES 5
Stachu
Community Champion
Community Champion

in PowerQuery you need to add new column with following syntax:

if Duration.Days(Date.From(DateTime.LocalNow()) - [Date Due])>=90 then 90 else 
if Duration.Days(Date.From(DateTime.LocalNow()) - [Date Due])>=60 then 60 else 
if Duration.Days(Date.From(DateTime.LocalNow()) - [Date Due])>=30 then 30 else 
0


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Thank you for the reply.

 

I've just tried to create a custom column called "Overdue Days" and then apply that but it's giving me an error.

 

Please see below. Any suggestions?

 

synt1.PNGreporting1.PNG

I assumed the [Due Date] is of type Date, while it's actually DateTime
this should work

if Duration.Days(DateTime.LocalNow() - [Date Due])>=90 then 90 else 
if Duration.Days(DateTime.LocalNow() - [Date Due])>=60 then 60 else 
if Duration.Days(DateTime.LocalNow() - [Date Due])>=30 then 30 else 
0

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

This worked perfectly, thank you

MarkHughes
Regular Visitor

Hello,

 

Data Source: SharePoint Online list

Developing in: PowerBI Desktop

 

I have a query about a query that I'm hoping some kind member of the community can help me with,

 

Issue

I need to have 3 count panels on my report to show a count of items that are overdue for 30, 60 & 90 days. The Column name is "Date Due" and I also have an "Overdue" column. I need assistance creating a calculation to look at the "Date Due" column and if it's 30, 60 or 90 days have passed from todays date, it must input either 30, 60 or 90 into the Overdue column based on the result.

 

Much appreciated

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.