Matching info in two sheets with time stamps

cmorriswilliams

New Member
Joined
Feb 3, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi there!

I have two sheets in one workbook. Sheet 1 will have a clock in and clock out for Employees. Sheet 2 will have a specific time stamp for when an employee performed a specific task.

I basically want to flag a YES if the Employee ex: Brian Poynter had a time stamp between his shift hours on 1/1/22.

SHEET 1
Driver NameClock In DateClock In TimeClock Out DateClock Out Time
ELD-Brian Poynter 1/1/202201:00 PM1/1/202209:00 PM
Fifth W- Swing - Chris Johnson1/1/202211:31 AM1/1/202209:25 PM
Fifth W- Swing -John Harrington1/1/202210:45 AM1/1/202208:06 PM
RO Swing - Mauricio Gonzalez1/2/202205:28 PM1/2/202208:51 PM

SHEET 2
Driver NameDate/Time Stamp
ELD-Brian Poynter
1/1/2022 2:41 PM​
ELD-Shari Banta
1/1/2022 2:48 AM​
*BP - Raj Singh
1/1/2022 4:23 PM​
*BP - Jay Morgan
1/1/2022 5:36 AM​
Raoul Bartsch
1/1/2022 5:51 PM​
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I loaded each tab into Power Query and merged the two (Left Outer Join on the Name). Then in the merged table, I filtered out the null results and then compared the Time Stamp to be between the clock in and clock out date

Here are the Mcode for each query

To transform sheet 1.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Clock In Date", type date}, {"Clock In Time", type time}}),
    #"Inserted Merged Date and Time" = Table.AddColumn(#"Changed Type", "Merged", each [Clock In Date] & [Clock In Time], type datetime),
    #"Changed Type1" = Table.TransformColumnTypes(#"Inserted Merged Date and Time",{{"Clock Out Date", type date}, {"Clock Out Time", type time}}),
    #"Inserted Merged Date and Time1" = Table.AddColumn(#"Changed Type1", "Merged.1", each [Clock Out Date] & [Clock Out Time], type datetime),
    #"Removed Columns" = Table.RemoveColumns(#"Inserted Merged Date and Time1",{"Clock In Date", "Clock In Time", "Clock Out Date", "Clock Out Time"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Merged", "Clocked In"}, {"Merged.1", "Clocked Out"}})
in
    #"Renamed Columns"

To transform sheet2
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date Time Stamp", type datetime}})
in
    #"Changed Type"

To Join the two tables and get results

Power Query:
let
    Source = Table.NestedJoin(Table1, {"Driver Name"}, Table2, {"Driver Name"}, "Table2", JoinKind.LeftOuter),
    #"Expanded Table2" = Table.ExpandTableColumn(Source, "Table2", {"Date Time Stamp"}, {"Table2.Date Time Stamp"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Table2", each ([Table2.Date Time Stamp] = #datetime(2022, 1, 1, 14, 41, 0))),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each if[Table2.Date Time Stamp]>[Clocked In] and [Table2.Date Time Stamp]<[Clocked Out] then "YES" else null)
in
    #"Added Custom"
 
Upvote 0
In addition to what already suggested by @alansidman above, if your data are in Sheet1!A:E and in Sheet2!A:B you could try the following formula in Sheet1!F2
Excel Formula:
=IF(SUM((Sheet2!A2:A10=A2)*((Sheet2!B2:B10)>=(B2+C2))*((Sheet2!B2:B10)<=(D2+E2)))>0,"YES","")
Then F2 copy down

Bye
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

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