Forum

Power Query Time Su...
 
Notifications
Clear all

Power Query Time Subtraction Issue

4 Posts
2 Users
0 Reactions
491 Views
(@jennis18)
Posts: 2
New Member
Topic starter
 

Hi,

I have extracted some Skype meeting data to Power Query, and I’m trying to determine the length of time that each user logged in to each meeting. I’m subtracting the meeting join time from the meeting leave time, however, in some cases the join time and the leave time appear to be equal (an IT glitch perhaps or a failed attempt to log into a meeting). In cases where the join time and leave time appear to be equal, I’m getting an error when performing the time subtraction, I seem to be getting negative duration values. Also, although the join time and leave time appear to be equal in these cases, if I perform a logical test to check for equality, Power Query returns a FALSE, so I’m really confused as to what’s happening. Is this something you’ve perhaps come across before?

I’ve attached a sample subset of the data.

I’m still getting to grips with Power Query, so apologies if the solution is really simple and obvious.

Thanks for your help.

Jack

 
Posted : 11/11/2022 9:23 am
Riny van Eekelen
(@riny)
Posts: 1195
Member Moderator
 

Hi Jack,

It's not at all obvious what's going on. When you change the format for User K in the Raw Data to Number and display plenty of decimals, you'll see that the times are not exactly the same.

In PQ, you need to work with regular numbers first and then replace negative values with 0 (zero).

Very recently, Phil touched on a conditionally replacing values in the link below and I just applied it to your data set.

https://www.myonlinetraininghub.com/excel-forum/power-query-members/conditional-table-replacevalue-not-working-with-nulls-or-blanks

Riny

 
Posted : 11/11/2022 11:01 am
(@jennis18)
Posts: 2
New Member
Topic starter
 

Hi Riny,

Thanks for your reply, it’s much appreciated.

It is strange, as you’ve said, when you clear the formatting for User K the join time is greater than the leave time, which makes no sense. I’m not sure what caused this, as I’ve imported the data directly from Skype Conference Detail Reports. In the data I’m working with, there are nearly 2,000 records, and this problem occurs 8 times, it’s a mystery.

Thank you for your suggestion. Would rounding the time values also work and, if so, are you familiar with rounding times in Power Query?

Many Thanks,

Jack

 
Posted : 11/11/2022 11:20 am
Riny van Eekelen
(@riny)
Posts: 1195
Member Moderator
 

As far as I know, you can only round number columns in PQ. So you need to change the data type for the Date/Time column to Decimal Number, then round to 5 decimals and change back to the Date/Time format. Tested it myself and the duration, for User K comes up as 00:00:00.

As you mentioned, it seems that the raw data comes with some "glitches" causing minute negative duration figures. If you are sure these are just glitches, it would be easier to just replace all negatives with zeroes as the rounding just adds steps and comes up with the same result.

 
Posted : 12/11/2022 2:33 am
Share: