cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Error calculating difference in days

 Hi all,

 

I am trying to calculate the difference between a due date and the date of today. I looked around a bit and found this formula, which might have been able to help me : Duration.Days(Duration.From(DateTime.LocalNow() - [DueDate]))

 

Now I added this formula in a custom column and it gives an error: 

replayyy_0-1594133649493.png

Does anybody have an idea of what I am doing wrong? I want to calculate the difference between the duedate and the date of today.

 

Kevin

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User IV
Super User IV

@replayyy as the error suggest, your columns need to be date/time type to apply duration function and seem like one of the column is only date not date/time

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.






Did I answer your question? Mark my post as a solution.

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





View solution in original post

2 REPLIES 2
Super User IV
Super User IV

@replayyy as the error suggest, your columns need to be date/time type to apply duration function and seem like one of the column is only date not date/time

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.






Did I answer your question? Mark my post as a solution.

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





View solution in original post

Thanks alot!

 

Solved is using = Duration.Days(Date.From(Duration.From(DateTime.LocalNow() - [DueDate]))

 

Atleast so it seems..

Helpful resources

Announcements
November Update

Check it Out!

Click here to read more about the November 2020 Updates!

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform October Community Highlights

Check out the top community contributors across all of the communities

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors