This can be accomplished through DAX or M, I chose to go with M and add the hours worked in the transform steps.
let
Source =
#“Changed Type” = Table.TransformColumnTypes(Source,{{“Emp ID”, Int64.Type}, {“Date”, type date}, {“From”, type time}, {“To”, type time}}),
#“Added Custom” = Table.AddColumn(#“Changed Type”, “To Date”, each if [To] < [From] then Date.AddDays( [Date], 1 ) else [Date]),
#“Changed Type1” = Table.TransformColumnTypes(#“Added Custom”,{{“To Date”, type date}}),
#“Inserted Merged Date and Time” = Table.AddColumn(#“Changed Type1”, “From DateTime”, each [Date] & [From], type datetime),
#“Inserted Merged Date and Time1” = Table.AddColumn(#“Inserted Merged Date and Time”, “To DateTime”, each [To] & [To Date], type datetime),
#“Inserted Time Subtraction” = Table.AddColumn(#“Inserted Merged Date and Time1”, “Duration”, each [To DateTime] - [From DateTime], type duration),
#“Removed Columns” = Table.RemoveColumns(#“Inserted Time Subtraction”,{“To Date”, “From DateTime”, “To DateTime”}),
#“Inserted Hours” = Table.AddColumn(#“Removed Columns”, “Hours Worked”, each Duration.Hours([Duration]) + (Duration.Minutes([Duration])/60)),
#“Changed Type2” = Table.TransformColumnTypes(#“Inserted Hours”,{{“Hours Worked”, type number}})
in
#“Changed Type2”
NOTE: I removed the source step in the quote above, because that was me typing in the source table into PowerBi, no need to see that here
From there, the DAX is simple, add up the hours worked.
Total Hours Worked = SUM( Schedule[Hours Worked] )
Full Solution is attached. I did add an additional employee (Jane) to demonstrate how this solution can include partial hours.
Hours Worked - Power Query solution.pbix (188.5 KB)