Elapsed Time in Power Query and PowerPivot

masterelaichi

New Member
Joined
Sep 29, 2014
Messages
49
Hi,

I wasn't able to find a thread on this topic so I thought I will go ahead and post one

I am trying to calculate the time elapsed between two timestamps in Power Query and Power Pivot. I need to see the result in minutes and extend it to hours if possible

Basically, I have a table which has two columns, Outage Start and Outage End. The values for these columns are of the format dd/mm/yyyy hh:min:sec AM/PM. For instance:

Outage Start: 24/11/2015 7:25:32 AM
Outage End : 24/11/2015 9:25:32 AM

I need to find the time elapsed between these two dates. I tried doing this through Power Query by creating a new custom column and then [Outage End-Outage Start], finally transforming it to a Duraration of type Minutes

The new custom column returns data in the format 00:4:40, for example. However, when I try converting this to minutes I get unexpected results. For example, for a time elapsed of say, 4hours, it doesn't give me the expected result of 240 minutes

Is there a way to do this in Power Query and also Power Pivot?

Thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You can do it in both. They use the same date/time approach to excel. Each day has a number starting at 1 for 1/1/1900 and then advancing by 1 each day. In power pivot you can simply subtract one date from another and get a date/time. You can format this as decimal and then multiply it be 24 to convert to hours.

In in power query, I think you can use built in functions in the menu to extract the components (date, hour, minute' second) en you can do the maths to find the difference.
 
Upvote 0
Thanks for your reply Matt

I think I have figured it out how to do it using Power Query (still have to test it thoroughly), although I am not sure how the Duration button works. What is the difference between Duration->hours, Minutes and Duration-> Total Hours, Total Minutes? They both give me different results

Powerpivot, on the other hand, doesn't seem to be working correctly. I am not sure if I am doing something wrong. When I try subtracting [Outage End]-[Outage Start] I get totally incorrect results. Ex- [24/03/2016 7:38:48 AM] - [24/03/2016 7:15:25 AM] gives me 30/12/1899 12:23:33 AM

Thanks
 
Upvote 0
In both cases, you can just subtract the end from the start. In Power Query, first add a custom column and then just do simple subtraction on the 2 columns. The issue you are seeing is that you have the new column formatted as date/time (which is the default for such calculation). Just change it to decimal number and it will give you the decimal days between the 2 dates. Multiply this by 24 to get total hours, 1440 to get total minutes etc.
 
Upvote 0

Forum statistics

Threads
1,224,158
Messages
6,176,745
Members
452,741
Latest member
Muhammad Nasir Mahmood

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top