Forum Discussion

chillpill's avatar
chillpill
Helper III
1 year ago
Solved

Remove duplicates and keep lowest (min) time

I have the data set below and need to find the earliest time and the associated activity for each date. I attempted a Group By with Min as an aggregate but wasn't successful.

 

 

Preferably, the results would look like the following. The status could either be Ready or Ringing depending on what time comes first on each date. 

 

EmployeeStatusDateTime
John SmithReady_11123112/97:13 AM
John SmithReady_11123112/107:06 AM
Margaret ChoReady_11123112/911:30 AM
Margaret ChoReady_11123112/1011:30 AM
Maddy KnockReady_111231

12/12

4:28 PM
Maddy KnockReady_11123112/1310:49 AM

 

The table formatting above works in the editing window but looks broken when posted. Sorry about that!

 

  • You can try the following code as your Table.Group

    = Table.Group(previousStep, {"Employee", "Date"}, {{"all", each Table.SelectRows(_, (r)=> r[Time] = List.Min([Time])), type table [Employee=nullable text, Status=nullable text, Date=nullable date, Time=nullable time]}})

    Then expand the resulting table with the Time and Status columns.

1 Reply

  • You can try the following code as your Table.Group

    = Table.Group(previousStep, {"Employee", "Date"}, {{"all", each Table.SelectRows(_, (r)=> r[Time] = List.Min([Time])), type table [Employee=nullable text, Status=nullable text, Date=nullable date, Time=nullable time]}})

    Then expand the resulting table with the Time and Status columns.