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

Calculate Time Difference (hours) excluding Weekends & Holidays

All,

I'm having issue to calculate cycle-time in hours between two days also exclude Weekends & Holidays. 

Sample data as follow:

Data:

IDDateStart TimeEnd Time
13/14/20203/13/19 3:45 PM3/14/19 4:46 PM
2

3/19/2020

3/6/19 2:00 PM3/27/19 3:58 PM

 

Reference Table:

I have this Date reference table to show dates and weekdays:

 

t_Date_Key = GENERATE(
CALENDAR (DATE ( 2012, 01, 01 ), DATE ( 2021, 12, 31 ) ),
VAR FullDate = [Date]
VAR DayNumber = DAY( FullDate )
VAR DayofWeek= FORMAT(FullDate,"DDDD")
VAR MonthN = MONTH ( FullDate )
VAR Month = FORMAT(FullDate,"MMMM")
VAR MonthYYYYMM = FORMAT(FullDate,"YYYYMM")
VAR years = YEAR ( FullDate )
VAR WeekN = WEEKNUM(FullDate)
VAR DayofWeekN = IF(WEEKDAY(FullDate)=1,7,WEEKDAY(FullDate)-1)
VAR WeekStarting = FullDate - DayofWeekN+1
VAR WeekEnding = FullDate - DayofWeekN +7
VAR Qtr = "Q" & ROUNDUP(MONTH(FullDate)/3,0)
RETURN ROW (
"Day Number", DayNumber,
"Year", years,
"Quarter",Qtr,
"Month N", MonthN,
"Month YYYYMM", MonthYYYYMM,
"Month",Month,
"Month N Y",Month&" "&years,
"Week N Y", WeekN,
"Day of Week", DayofWeek,
"Day of Week N",DayofWeekN,
"Week Starting",WeekStarting,
"Week Ending",WeekEnding
))

 

I also have a holiday Reference table to show each holiday accros the year, linked with data table.

Snipaste_2020-12-02_12-02-59.png

I have researched a lot but most of solutions is to count each workday as 1, sum workdays exclude weekends and holidays, which is not accurate in my case. Some of the request came in late afternoon, like 3:45PM, SME doesnt have time to work on that day but finish early next morning like 9AM, but result of this calculation give 2 workdays duration which make report to show SME missed SLA. 

 

Please advise any good solution to calculate duration in hours excluding holidays & weekends,

Thank you!

 

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hi, @Anonymous 


Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?
Other community members will easily find the solution when they get the same issue.

Best Regards,
Community Support Team _ Eason

amitchandak
Super User
Super User

@Anonymous ,please check the attached file can help

or this blog :https://curbal.com/blog/glossary/networkdays-dax

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.