Forum

Time and Attendance
 
Notifications
Clear all

Time and Attendance

9 Posts
5 Users
0 Reactions
193 Views
(@corrie-hiepner)
Posts: 7
Active Member
Topic starter
 

Hi Mynda,

 

I just watched your video on Extracting Start and End Dates from a list and would like to know how to apply this in my situation where I have a list of employee numbers, the date and the time they clocked in or out  using the bio-metric system.  Unfortunately there is no specific Time In and Time Out column.  All the data is in the same column which is making it very difficult for me. I need to extract the First Time In and the Last Time Out per employee no per date.

I've attached a file with an example of the data and the desired outcome. 

Any advice/assistance will be greatly appreciated.

 
Posted : 11/01/2020 8:40 am
(@purfleet)
Posts: 412
Reputable Member
 

Hi Corrie

I have no idea about power query and i sure someone will respond, but you could do what you want with a pivot table if it helps

Purfleet

 
Posted : 11/01/2020 4:35 pm
(@bluesky63)
Posts: 162
Estimable Member
 

Hi Corrie

Attached is the Power Query solution

First you need to group by Employee No and Date,  for Aggregation,  one for Min and one for Max

 
Posted : 12/01/2020 9:08 am
(@corrie-hiepner)
Posts: 7
Active Member
Topic starter
 

Hi Chris,

Thank you so much!  You make it look so easy 🙂

Much appreciated!

 
Posted : 14/01/2020 2:24 am
(@corrie-hiepner)
Posts: 7
Active Member
Topic starter
 

Hi, I posted this earlier this year, and @Chris Yap, was able to assist, but I have a further complication now, as a Night Shift has been added to the mix.  Chris was able to show me how to determine the First Time In and the Last Time Out, but with night shift, this spans over 2 dates/days.  Can anyone advise how to achieve the same result for night shift?

I've attached the original file, with Chris's solution and a representation of my desired outcome.

Once again, any advice on how to do this is greatly appreciated.

 
Posted : 04/06/2020 7:09 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Corrie,

no file attached.

regards

Phil

 
Posted : 05/06/2020 12:58 am
(@corrie-hiepner)
Posts: 7
Active Member
Topic starter
 

Hi Phil,

Apologies, please see attached.

Thank you

 
Posted : 05/06/2020 2:01 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi Corrie,

Without proper data, there is no easy way, just workarounds, and there are chances to fail in specific scenarios.

You can try this query:

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Employee No", type text}, {"Date", type date}, {"Time", type time}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "New Date", each if [Time]<=#time(4,30,0) then Date.AddDays([Date],-1) else [Date]),
#"Grouped Rows1" = Table.Group(#"Added Custom", {"New Date"}, {{"Count", each _, type table [Employee No=text, Date=date, Time=time, Custom=date, Index=number]}}),
#"Added Custom2" = Table.AddColumn(#"Grouped Rows1", "Date-Time In", each Number.From(List.First([Count][Date]))+Number.From(List.First([Count][Time])), type datetime),
#"Added Custom3" = Table.AddColumn(#"Added Custom2", "Date-Time Out", each Number.From(List.Last([Count][Date]))+Number.From(List.Last([Count][Time])),type datetime),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom3",{{"Date-Time In", type datetime}, {"Date-Time Out", type datetime}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Count", "New Date"})
in
#"Removed Columns"

As you can see, the query converts the date for entries where time is below 4:30 AM, the date will be 1 day before entry Date, this new date will be used for grouping. The grouping must return all rows, will not be a min or max, a table with all entries for that date will be returned.

From this grouped table, we simply take the first and last entries.

 
Posted : 05/06/2020 6:32 am
(@corrie-hiepner)
Posts: 7
Active Member
Topic starter
 

Hi Catalin,

Your assistance is much appreciated.

I was able to apply your code to my dataset and it worked.

Thank you

 
Posted : 12/06/2020 4:33 am
Share: