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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
AntonioCarl
Helper I
Helper I

Help needed with Power Query query which calculates working hours

Hi, 

I've got a table 

Employee_idDateTimeType
63002.01.2024 00:00:0009:45:50IN
63002.01.2024 00:00:0017:02:40OUT
63013.02.2024 00:00:0016:06:30OUT
63017.09.2024 00:00:0006:37:50IN
63017.09.2024 00:00:0008:07:30OUT
63017.09.2024 00:00:0008:21:00IN
63017.09.2024 00:00:0016:20:00

 

 

 

 

For each employee_id and each date I need to find IN and OUT pairs. 

If there's pair IN and OUT return IN and OUT in pair-rows. In my example theres going to be one row for 02.01.2024 but two rows for 17.09.2024 and it means that employee left company in middle of the day. 

Theres also case that he forgot to Clock in or clock out. Then I need to add proper description to new column. 

I've tried to do write it myself  but failed 😞 


What I want to achieve is basically something like that. 

Employee_idDateINOUTDESCRIPTION
63002.01.2024 00:00:0009:45:5017:02:40 
63013.02.2024 00:00:00null16:06:30NOT CLOCKED IN 
63017.09.2024 00:00:0006:37:5008:07:30 
63017.09.2024 00:00:0008:21:0016:20:00 
2 REPLIES 2
v-jtian-msft
Community Support
Community Support

Hi,amitchandak .thanks for your concern about this issue.

Hello,@AntonioCarl .

Has your problem been solved?
If you have found suitable solutions, please share them as it will help more users with similar problems.
Or you can mark the valid suggestions provided by other users as solutions.
Thank you very much for your understanding and support of Power BI.

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



amitchandak
Super User
Super User

@AntonioCarl , First you can Pivot data using Type and Time tbale. 

 

Then you can have an additional column in power query

 

= if [out] = null then "NOT ClOCKED IN" else ""

 

Pivot Data(Power Query) :https://www.youtube.com/watch?v=oKByyI09Bno&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=12

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.