Forum

Datedif in Power qu...
 
Notifications
Clear all

Datedif in Power query - finding the Completed years, months and days (YY MM DD) between start date and end date

3 Posts
2 Users
0 Reactions
205 Views
(@sanpeur)
Posts: 5
Active Member
Topic starter
 

Hi,

I've been reading with interest the comments at https://www.myonlinetraininghub.com/secret-excel-function-datedif concerning Datedif.

I have used this within Excel in particular to find the difference between start date and end date in terms of completed years, months and days.

I had posted a question on how to do this in PowerQuery rather than DAX for use in Excel or Power BI at

https://blogs.msdn.microsoft.com/samlester/2017/04/06/calculating-the-difference-between-two-dates-in-years-months-and-days-in-power-bi-or-excel/

however did not receive a reply.

Since then I have managed to (clumsily) achieve this using the UI only.  I'm not a programmer nor coder.  Definitely can use XL formulae!  I did it in PQ as if I was doing it on a bit of paper with a pen!

There surely would be a simpler / more elegant solution?  Happy to discuss the methodology / theory of achieving this rather than being provided with an alternate code.

 

Cheers

 

SP

 

(Mynda - I tried submitting this before but it failed.  Please delete the other one!)

 
Posted : 02/04/2019 5:58 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Sylvain,

Thanks for sharing your solution. I had a quick look at your file but there are a lot of steps so I didn't spend time trying to follow it all!

I can't imagine there's a much easier way because we simply don't have the logic in Power Query M for a DATEDIFF equivalent.

Mynda

 
Posted : 02/04/2019 9:49 pm
(@sanpeur)
Posts: 5
Active Member
Topic starter
 

Hi Mynda , 

Thanks for looking at my steps. Am sure it could be simplified / consolidated.   Regardless it does work which doesn't seen to be an intrinsic issue in relation to timing of execution. 

Cheers

SP

 
Posted : 10/04/2019 5:10 am
Share: