I know this question has been asked a bunch of times before, but I think I have a unique nuance to the question. We use Zendesk in our business and I am trying to calculate the average number of work days it takes between when a ticket is created and when it’s solved. Based on this video by Brian, I was able to come up with this script:
When I export the data to Excel and do my own calculations, the above creates the exact same result as subtracting the two dates in Excel and adding 1. However, if I were to use the NETWORKDAYS function in Excel, it results in a lower average than what the above DAX formula returns. My hypothesis, therefore, is that I am not correctly removing “Saturday” and “Sunday” in the DAX formula.
How about creating a calculated column and getting the days by subtracting the Solved Date from Tickets Created Date and then getting the Average?
The Created Date/Time was first transformed into Create Date (Date Format) in Power Query and then created a calculated column using
Days To Solve =
DATEDIFF(
‘Table’[Ticket Created Date],
‘Table’[Solved Date],
DAY)
Then calculated the Average using the measure
Average Days CC Workdays =
VAR TotalDaysToSolve = [Total Days To Solve]
VAR DaysExcludingWeekends =
CALCULATE (
COUNTROWS ( ‘Date’ ),
FILTER (
ALL ( ‘Date’[DayOfWeek] ),
‘Date’[DayOfWeek] <> 0
&& ‘Date’[DayOfWeek] <> 6
)
)
VAR Result =
DIVIDE ( TotalDaysToSolve, DaysExcludingWeekends )
RETURN
Result