get the earliest login time among dates

uwmarkyo

New Member
Joined
Aug 11, 2021
Messages
43
Office Version
  1. 365
Platform
  1. Windows
I have a sample like this: dataset
1674595793977.png


I tried to get the earliest login time for certain date and certain agent:
1674596111142.png


I am not able to get the result I want. can someone give me a guidance?
dataset
Thanks,
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Im not sure if you wanted the min by date or agent, so this has both.
Does this work for you?
Mr Excel Questions.xlsx
ABCDEFGHIJK
1
2Agent_NmDatelogin timelogout time
3Apple1/4/20238:00:0916:30:18NameEarliest Login by NameDateEarliest Login by Date
4Apple1/5/20238:01:2916:31:08Apple8:00:09 AM1/3/20237:55:00 AM
5Apple1/6/20238:12:2216:31:32Apricot8:00:27 AM1/4/20237:54:37 AM
6Apricot1/3/20238:00:4316:31:30Asian Pear8:00:36 AM1/5/202312:48:22 AM
7Apricot1/4/20238:19:0816:31:02Avocado8:00:20 AM1/6/20237:57:23 AM
8Apricot1/5/20238:00:2716:31:45Banana8:58:02 AM1/8/20233:13:52 AM
9Avocado1/4/20238:00:4316:30:10Bell fruit8:00:07 AM
10Avocado1/6/20238:00:2016:30:04Blueberry8:00:27 AM
11Banana1/3/20238:58:0217:34:21Breadfruit8:51:38 AM
12Banana1/4/20238:58:4617:37:37Cherry7:59:26 AM
13Banana1/5/20239:00:0917:31:13Chinese Bayberry3:13:52 AM
14Banana1/6/20238:58:2717:31:41Coconut7:59:34 AM
15Blueberry1/3/20238:30:408:32:25Dragon Fruit8:30:32 AM
16Blueberry1/3/20238:32:2710:03:41Durian10:30:43 AM
17Blueberry1/3/202310:03:4210:40:37Fig10:30:07 AM
18Blueberry1/3/202310:40:3814:05:21Grape7:59:04 AM
19Blueberry1/3/202314:05:2217:00:15Grapefruit7:58:28 AM
20Blueberry1/4/20238:29:2510:34:52Jackfruit12:48:22 AM
21Blueberry1/4/202311:09:4416:33:10Japanese Persimmon9:00:34 AM
Sheet7
Cell Formulas
RangeFormula
F4:G51F4=LET( nm,AgentTime[Agent_Nm], lcol,SORT(UNIQUE(AgentTime[Agent_Nm])), ss,AgentTime[login time], mt,MINIFS(ss,nm,lcol), HSTACK(lcol,mt))
I4:J8I4=LET( dt,AgentTime[Date], lcol,SORT(UNIQUE(dt)), ss,AgentTime[login time], mt,MINIFS(ss,dt,lcol), HSTACK(lcol,mt))
Dynamic array formulas.
 
Upvote 0
With Power Query earliest Login by Name

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"login time", type time}, {"logout time", type time}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Agent_Nm"}, {{"Earliest Login", each List.Min([login time]), type nullable time}})
in
    #"Grouped Rows"

Earliest login by date

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"login time", type time}, {"logout time", type time}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Date"}, {{"Earliest Login", each List.Min([login time]), type nullable time}})
in
    #"Grouped Rows"
 
Upvote 0
Im not sure if you wanted the min by date or agent, so this has both.
Does this work for you?
Mr Excel Questions.xlsx
ABCDEFGHIJK
1
2Agent_NmDatelogin timelogout time
3Apple1/4/20238:00:0916:30:18NameEarliest Login by NameDateEarliest Login by Date
4Apple1/5/20238:01:2916:31:08Apple8:00:09 AM1/3/20237:55:00 AM
5Apple1/6/20238:12:2216:31:32Apricot8:00:27 AM1/4/20237:54:37 AM
6Apricot1/3/20238:00:4316:31:30Asian Pear8:00:36 AM1/5/202312:48:22 AM
7Apricot1/4/20238:19:0816:31:02Avocado8:00:20 AM1/6/20237:57:23 AM
8Apricot1/5/20238:00:2716:31:45Banana8:58:02 AM1/8/20233:13:52 AM
9Avocado1/4/20238:00:4316:30:10Bell fruit8:00:07 AM
10Avocado1/6/20238:00:2016:30:04Blueberry8:00:27 AM
11Banana1/3/20238:58:0217:34:21Breadfruit8:51:38 AM
12Banana1/4/20238:58:4617:37:37Cherry7:59:26 AM
13Banana1/5/20239:00:0917:31:13Chinese Bayberry3:13:52 AM
14Banana1/6/20238:58:2717:31:41Coconut7:59:34 AM
15Blueberry1/3/20238:30:408:32:25Dragon Fruit8:30:32 AM
16Blueberry1/3/20238:32:2710:03:41Durian10:30:43 AM
17Blueberry1/3/202310:03:4210:40:37Fig10:30:07 AM
18Blueberry1/3/202310:40:3814:05:21Grape7:59:04 AM
19Blueberry1/3/202314:05:2217:00:15Grapefruit7:58:28 AM
20Blueberry1/4/20238:29:2510:34:52Jackfruit12:48:22 AM
21Blueberry1/4/202311:09:4416:33:10Japanese Persimmon9:00:34 AM
Sheet7
Cell Formulas
RangeFormula
F4:G51F4=LET( nm,AgentTime[Agent_Nm], lcol,SORT(UNIQUE(AgentTime[Agent_Nm])), ss,AgentTime[login time], mt,MINIFS(ss,nm,lcol), HSTACK(lcol,mt))
I4:J8I4=LET( dt,AgentTime[Date], lcol,SORT(UNIQUE(dt)), ss,AgentTime[login time], mt,MINIFS(ss,dt,lcol), HSTACK(lcol,mt))
Dynamic array formulas.
Thanks for your quick respond.
I tried this method. I didn't get it right.
I think it's because I don't know what dynamic array formula is.

in my dataset, I have another tab is for result. the result formula should look up agent name, date, and find the earliest login time.
1674612396998.png
 
Upvote 0
With Power Query earliest Login by Name

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"login time", type time}, {"logout time", type time}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Agent_Nm"}, {{"Earliest Login", each List.Min([login time]), type nullable time}})
in
    #"Grouped Rows"

Earliest login by date

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"login time", type time}, {"logout time", type time}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Date"}, {{"Earliest Login", each List.Min([login time]), type nullable time}})
in
    #"Grouped Rows"
This method also works ideally. I never thought of using power query. Great inspiration, thanks.
However, I would like to learn a formula method in order to gain more knowledge.
 
Upvote 0
Here is a solution with more basic formulas.

Mr Excel Questions.xlsx
ABCDEFGH
1
2Agent_NmDatelogin timelogout time
3Apple1/4/20238:00:0916:30:18NameTime of Earliest Log InDate of Earliest Login
4Apple1/5/20238:01:2916:31:08Apple8:00:09 AM1/4/2023
5Apple1/6/20238:12:2216:31:32Apricot8:00:27 AM1/6/2023
6Apricot1/3/20238:00:4316:31:30Asian Pear8:00:36 AM1/5/2023
7Apricot1/4/20238:19:0816:31:02Avocado8:00:20 AM1/6/2023
8Apricot1/5/20238:00:2716:31:45Banana8:58:02 AM1/3/2023
9Asian Pear1/3/20238:01:5616:30:40Bell fruit8:00:07 AM1/3/2023
10Asian Pear1/4/20238:01:2416:35:41Blueberry8:00:27 AM1/6/2023
11Asian Pear1/5/20238:01:5116:31:24Breadfruit8:51:38 AM1/6/2023
12Asian Pear1/6/20238:00:3616:30:26Cherry7:59:26 AM1/5/2023
13Avocado1/4/20238:00:4316:30:10Chinese Bayberry3:13:52 AM1/6/2023
14Avocado1/6/20238:00:2016:30:04Coconut7:59:34 AM1/8/2023
15Banana1/3/20238:58:0217:34:21Dragon Fruit8:30:32 AM1/6/2023
16Banana1/4/20238:58:4617:37:37Durian10:30:43 AM1/3/2023
Get Min Time Agent 2
Cell Formulas
RangeFormula
F4:F51F4=SORT(UNIQUE(AgentTime2[Agent_Nm]))
G4:G16G4=MINIFS(AgentTime2[login time],AgentTime2[Agent_Nm],F4)
H4:H16H4=INDEX(AgentTime2[Date],MATCH(F4&G4,AgentTime2[Agent_Nm]&AgentTime2[login time]))
Dynamic array formulas.
 
Upvote 0
Here is a solution with more basic formulas.

Mr Excel Questions.xlsx
ABCDEFGH
1
2Agent_NmDatelogin timelogout time
3Apple1/4/20238:00:0916:30:18NameTime of Earliest Log InDate of Earliest Login
4Apple1/5/20238:01:2916:31:08Apple8:00:09 AM1/4/2023
5Apple1/6/20238:12:2216:31:32Apricot8:00:27 AM1/6/2023
6Apricot1/3/20238:00:4316:31:30Asian Pear8:00:36 AM1/5/2023
7Apricot1/4/20238:19:0816:31:02Avocado8:00:20 AM1/6/2023
8Apricot1/5/20238:00:2716:31:45Banana8:58:02 AM1/3/2023
9Asian Pear1/3/20238:01:5616:30:40Bell fruit8:00:07 AM1/3/2023
10Asian Pear1/4/20238:01:2416:35:41Blueberry8:00:27 AM1/6/2023
11Asian Pear1/5/20238:01:5116:31:24Breadfruit8:51:38 AM1/6/2023
12Asian Pear1/6/20238:00:3616:30:26Cherry7:59:26 AM1/5/2023
13Avocado1/4/20238:00:4316:30:10Chinese Bayberry3:13:52 AM1/6/2023
14Avocado1/6/20238:00:2016:30:04Coconut7:59:34 AM1/8/2023
15Banana1/3/20238:58:0217:34:21Dragon Fruit8:30:32 AM1/6/2023
16Banana1/4/20238:58:4617:37:37Durian10:30:43 AM1/3/2023
Get Min Time Agent 2
Cell Formulas
RangeFormula
F4:F51F4=SORT(UNIQUE(AgentTime2[Agent_Nm]))
G4:G16G4=MINIFS(AgentTime2[login time],AgentTime2[Agent_Nm],F4)
H4:H16H4=INDEX(AgentTime2[Date],MATCH(F4&G4,AgentTime2[Agent_Nm]&AgentTime2[login time]))
Dynamic array formulas.
Thanks for your help.
I just notice one thing, this blue table is exactly what I need. Can you show me how you formula this? Thanks
1674663492490.png
 

Attachments

  • 1674663179377.png
    1674663179377.png
    75.9 KB · Views: 4
Upvote 0
@uwmarkyo , the blue table in my answer is just your agent data table moved onto the same spreadsheet i was doing my work on. I guess I did not understand your question correctly.

What is the significance of the last picture image? What question do you have about that? The two columns in my solution are independent of each other, based upon my interpretation of your question. If you want the DATE that the AGENT logged on at the earliest time, it is another calculation.
 
Upvote 0
@uwmarkyo , the blue table in my answer is just your agent data table moved onto the same spreadsheet i was doing my work on. I guess I did not understand your question correctly.

What is the significance of the last picture image? What question do you have about that? The two columns in my solution are independent of each other, based upon my interpretation of your question. If you want the DATE that the AGENT logged on at the earliest time, it is another calculation.

Sorry that I didn't explain clearly.
As you can see this is part of my dataset,
1674672345347.png


Blueberry has multiple logins and logouts on the same date.
Ideally, it will show every agent's earliest login time and the last logout time on each day as below,
1674672563512.png


thanks for your patience.
 
Upvote 0
How about
sample.xlsx
ABCDEFGHIJ
1Agent_NmDatelogin timelogout time
2Apple04/01/202308:00:0916:30:18Apple04/01/202308:00:0916:30:18
3Apple05/01/202308:01:2916:31:08Apple05/01/202308:01:2916:31:08
4Apple06/01/202308:12:2216:31:32Apple06/01/202308:12:2216:31:32
5Apricot03/01/202308:00:4316:31:30Apricot03/01/202308:00:4316:31:30
6Apricot04/01/202308:19:0816:31:02Apricot04/01/202308:19:0816:31:02
7Apricot05/01/202308:00:2716:31:45Apricot05/01/202308:00:2716:31:45
8Avocado04/01/202308:00:4316:30:10Avocado04/01/202308:00:4316:30:10
9Avocado06/01/202308:00:2016:30:04Avocado06/01/202308:00:2016:30:04
10Banana03/01/202308:58:0217:34:21Banana03/01/202308:58:0217:34:21
11Banana04/01/202308:58:4617:37:37Banana04/01/202308:58:4617:37:37
12Banana05/01/202309:00:0917:31:13Banana05/01/202309:00:0917:31:13
13Banana06/01/202308:58:2717:31:41Banana06/01/202308:58:2717:31:41
14Blueberry03/01/202308:30:4008:32:25Blueberry03/01/202308:00:2717:00:15
15Blueberry03/01/202308:32:2710:03:41Blueberry04/01/202308:00:3016:33:10
16Blueberry03/01/202310:03:4210:40:37Blueberry05/01/202308:00:4217:00:03
17Blueberry03/01/202310:40:3814:05:21Blueberry06/01/202308:00:4417:00:08
18Blueberry03/01/202314:05:2217:00:15Cherry03/01/202307:59:2616:35:40
19Blueberry04/01/202308:29:2510:34:52Cherry04/01/202308:00:3716:32:13
20Blueberry04/01/202311:09:4416:33:10Cherry05/01/202307:59:2616:29:27
21Blueberry05/01/202308:30:0817:00:03Cherry06/01/202308:00:4016:29:11
22Blueberry06/01/202308:30:2610:02:39Coconut03/01/202308:05:3816:33:53
23Blueberry06/01/202310:07:4112:12:28Coconut04/01/202307:59:5616:31:05
24Blueberry06/01/202312:12:3016:57:34Coconut05/01/202308:00:2016:31:22
25Blueberry06/01/202316:57:3617:00:08Coconut06/01/202307:59:3416:30:13
26Cherry03/01/202307:59:2616:35:40Grape03/01/202307:59:3016:30:03
27Cherry04/01/202308:00:3716:32:13Grape04/01/202307:59:3716:30:26
28Cherry05/01/202307:59:2616:29:27Grape05/01/202307:59:1616:30:01
29Cherry06/01/202308:00:4016:29:11Grape06/01/202307:59:0416:30:02
30Coconut03/01/202308:05:3816:33:53Grapefruit03/01/202308:04:0416:31:56
Agent_log
Cell Formulas
RangeFormula
G2:H182G2=UNIQUE(AgentTime[[Agent_Nm]:[Date]])
I2:I182I2=MINIFS(C:C,A:A,INDEX(G2#,,1),B:B,INDEX(G2#,,2))
J2:J182J2=MAXIFS(D:D,A:A,INDEX(G2#,,1),B:B,INDEX(G2#,,2))
Dynamic array formulas.



But you will need to change the login & logout "times2 to actual time, rather than text.
 
Upvote 0
Solution

Forum statistics

Threads
1,216,101
Messages
6,128,835
Members
449,471
Latest member
lachbee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top