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
Anonymous
Not applicable

Determining if a day/time is outside of business hours

Very new to Power BI.  Just trying to nail down a true or false column for determining if a day/time is outside of business hours.  My business hours are Monday to Friday, 9am to 5pm.  I have a column of existing data that reports when a case is opened 'Case'[CreatedDate] - shown as 6/29/2017 2:19:47 PM.  I have a table that also includes all our corporate closure days (holidays).  So I'm trying to create a column that shows

 

IsAfterHours = If 'Case'[CreatedDate].[Day] = "Saturday OR Sunday" ,True, "False"  OR If 'Case'[CreatedDate].[Time] >5:00:00 PM,<9:00:00, True, False

 

ideally, I'd also tie in my Afterhours calc to the Holiday table also, but that I have that displaying already. 

 

Excel makes this sort of easy, =IF(OR(WEEKDAY(CELL)=1,WEEKDAY(CELL)=7),TRUE,IF(OR(CELL<9/24,CELL>17/24),TRUE,""))  I'm looking to create the same thing in Power BI. 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

 

Created this calculated column formula

 

=IF(WEEKDAY(INT('Case'[CreatedDate]),2)>=6,TRUE(),IF(OR(MOD('Case'[CreatedDate],1)<TIME(9,0,0),MOD('Case'[CreatedDate],1)>TIME(17,0,0)),TRUE(),FALSE()))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

1 REPLY 1
Ashish_Mathur
Super User
Super User

Hi,

 

Created this calculated column formula

 

=IF(WEEKDAY(INT('Case'[CreatedDate]),2)>=6,TRUE(),IF(OR(MOD('Case'[CreatedDate],1)<TIME(9,0,0),MOD('Case'[CreatedDate],1)>TIME(17,0,0)),TRUE(),FALSE()))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.