The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I am trying to create a report that displays the average time to reolve a ticket in the last 30 days. This must exclude weekends.
How can I achieve this with DAX?
Solved! Go to Solution.
Hi @Radhika_Kanaka ,
You will need to create a weekday column.
Best Regards,
Jay
Hi @Radhika_Kanaka ,
You will need to create a weekday column.
Best Regards,
Jay
When I tried to invoke the function with Datetime datatype columns. The resultant custom column is displaying the below error:
Expression.Error: We cannot convert the value #datetime(2022, 3, 22, 17, 34, 0) to type Date.
Details:
Value=3/22/2022 5:34:00 PM
Type=[Type]
if this the custom function
(InitialDate as date, FinalDate as date ) as number => let DaysBetweenDates = Duration.Days(FinalDate-InitialDate), DaysList = List.Dates(List.Min({InitialDate,FinalDate}),Number.Abs(DaysBetweenDates)+1, Duration.From(1)), WeekDaysList = List.Select(DaysList, each (Date.DayOfWeek(_, Day.Monday) < 5) ), WorkingDays = (if DaysBetweenDates < 0 then -1 else 1) * List.Count(WeekDaysList) in WorkingDays
You might want to consider InitialDate as datetime, FinalDate as datetime
@Tutu_in_YYC Thank you for your quick response.
I managed to get M code that displays resolution time in days excluding weekends. My requirement is to get the resolution time (difference between created date and resolved date)in hours, minutes, seconds. M code is new to me. Would you be able to help on this?? Attaching the M code for reference. Appreciate your response.
(InitialDate as date, FinalDate as date ) as number => let DaysBetweenDates = Duration.Days(FinalDate-InitialDate), DaysList = List.Dates(List.Min({InitialDate,FinalDate}),Number.Abs(DaysBetweenDates)+1, Duration.From(1)), WeekDaysList = List.Select(DaysList, each (Date.DayOfWeek(_, Day.Monday) < 5) ), WorkingDays = (if DaysBetweenDates < 0 then -1 else 1) * List.Count(WeekDaysList) in WorkingDays
Hi Radhika,
There are so many options, it will depends on the data that you have and how you want to model it. If you have some sample data that you are working on, we can probably figure out a direction and try to leverage the function DATEDIFF.
But the general idea is to use time-intelligence functions to generate the metrics you want to track. Have a look at these DAX patterns
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
25 | |
13 | |
12 | |
8 | |
8 |