Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply

Identify if any part of a duration between 2 date/times is within working hours

Bit stuck with this one!

 

I've been asked to provide a count of planned works that have any part of the planned duration, during working hours.

 

I have a Reference, and 2 date/times, and I want to derive a final column as a Yes/No.  Example data, with final column as the calculated column I want to return.

 

WorkIDStartEndIn working hours?
WO112211/01/2021 19:0011/01/2021 23:00No
WO123411/01/2021 16:0011/01/2021 19:00Yes
WO113511/01/2021 09:0011/01/2021 14:00Yes

 

WorkIDStartEndIn working hours?
WO112211/01/2021 19:0011/01/2021 23:00No
WO123411/01/2021 16:0011/01/2021 19:00Yes
WO113511/01/2021 09:0011/01/2021 14:00Yes

 

Working hours are 08:00 to 18:00, Monday to Friday.

 

I've got similar 'stuff' for working days, but that requires a calendar table with Working Days flagged.  I don't think having every possible date/time in a table to flag a working hour is the way to go here, but am a bit stuck on the logic.

 

Any clues/ideas?

 

Thanks so much!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@silverdale9999 , Try a new column like

 

new column =
var _st = [Start].time // or time(hour([start]),minute([start]),Second([start]))
var _end = [end].time // or time(hour([end]),minute([end]),Second([end]))
return
if(_st<= time(18,0,0) && _end>=Time(8,0,0), "Yes", "No")

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@silverdale9999 , Try a new column like

 

new column =
var _st = [Start].time // or time(hour([start]),minute([start]),Second([start]))
var _end = [end].time // or time(hour([end]),minute([end]),Second([end]))
return
if(_st<= time(18,0,0) && _end>=Time(8,0,0), "Yes", "No")

Thanks!! This works.  (I've not fully tested, but seems to do what I am expecting 🙂 )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.