Forum

Loop Through List f...
 
Notifications
Clear all

Loop Through List for Min/Max to Calculate Duration

2 Posts
2 Users
0 Reactions
42 Views
(@shellp_55)
Posts: 4
Active Member
Topic starter
 

Hello,

I have a list of various computer user events i.e. login, logout, shutdown etc.  Originally I created a min date/time per date and a max date/time per date and merged the two so I had the min/max to calculate duration.  But that doesn't work for split shifts or anyone having to leave for appointments and returning to work.   

I have attached a workbook with fake data showing the "pairings" I would like to be using for the duration calculations.   How should I approach it to get the results I'd like?  All assistance greatly appreciated.

 

 
Posted : 24/04/2025 3:37 am
Alan Sidman
(@alansidman)
Posts: 222
Member Moderator
 

 

If I understand correctly then, Power Query will do the work 

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Access_Date", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Access_Date", "Employee"}, {{"Login", each List.Min([#"Access Date/Time"]), type datetime}, {"Logout", each List.Max([#"Access Date/Time"]), type datetime}})
in
#"Grouped Rows"
 
Posted : 24/04/2025 6:12 am
Share: