The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi Experts,
My apologies if I am posting in wrong place.
I am having a requirement, where I have to calculate Target start date(Acknowledgement date/time for Response SLA) and Target Finish Date(Resolution Date/Time for Resolution SLA) based on the incidents (Ticket) created date. In my case I have only Reported Date(Created Date of Incident) and using that I have to calculate Response and Resolution Dates by excluding the Weekends and Non-Business Hours.
Can someone kindly help on this.
If I am posting this in the wrong forum, please guide me on where should I post this.
Thanks in advance.
Regards,
Madhavan
Thanks Alex.
But I guess these will work if we have 2 dates like start and end dates.
In my case I am having only one date column, the created date of incident and I have to calculate Target start date(Acknowledgement date/time for Response SLA) and Target Finish Date(Resolution Date/Time for Resolution SLA) using the created date based on the priority of the ticket created.
Please let me know if any additional info required.
try this one Calculate Nth Business Day From Date in Power Query - BI Gorilla
Edit:
I tested this function specifically myself but it's copied directly from link above. Seems to do the job. You'd need to plug in your own holidays though.
let func =
( ReferenceDate as date, WorkdayOffset as number, optional Holidays as list) =>
let
/* Debug parameters
ReferenceDate = #date( 2021,1,1 ),
WorkdayOffset = 1,
Holidays = { #date( 2021,1,1 ) },
*/
// Returns empty list if Holidays are omitted
BufferedHolidays = List.Buffer( Holidays ?? {} ),
// Determines the positive or negative offset of Date.AddDays
AddDays = Number.Sign( WorkdayOffset ),
// Creates the List of Dates until it reaches the relevant Workday
ListOfDates =
List.Generate(
() => [
Date = Date.AddDays( ReferenceDate, AddDays ),
WD_Counter = 0,
IsWorkday = null
],
each if [WD_Counter] = Number.Abs( WorkdayOffset )
and [IsWorkday] = true then false else true,
each
let
NextDateIsWD = Date.DayOfWeek([Date], 1)
< 5 and not List.Contains( BufferedHolidays, [Date])
in
[
Date = Date.AddDays([Date], AddDays ),
WD_Counter = if NextDateIsWD then [WD_Counter] + 1
else [WD_Counter],
IsWorkday = NextDateIsWD
],
each [Date]
),
// Returns the relevant Workday, which is always last in the list
RelevantWorkday = List.Last( ListOfDates ),
// When 0 is used as Workdayoffset, the function returns the referencedate
Result = if WorkdayOffset = 0 then ReferenceDate else RelevantWorkday
in
Result,
documentation = [
Documentation.Name = " WORKDAY ",
Documentation.Description = " Function returns the date that lies an specfied number of business days from the reference date. ",
Documentation.LongDescription = " Function returns the date that lies an specfied number of business days from the reference date. The function takes into account weekends and can optionally respect a list of holiday dates. ",
Documentation.Category = " Nth Business Day ",
Documentation.Source = " https://gorilla.bi – https://gorilla.bi/power-query/nth-business-day-from-date/ ",
Documentation.Version = " 1.0 ",
Documentation.Author = " Rick de Groot",
Documentation.Examples = {[Description = " ",
Code = " let
ReferenceDate = #date( 2022, 9, 15 ),
WorkdayOffset = 2,
Holidays = { #date( 2022, 9, 19 ) },
Result = WORKDAY( ReferenceDate, WorkDayOffset, Holidays )
in
Result ",
Result = " #date(2022, 9, 20)
"]}]
in
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation))
Tried, but no luck, as we need to consider only business hours along with exclusion of weekends.
I'm not sure on how to work out on this as I am new to Power BI and I have developed a basic report only. But I'll give it a try though. Thank you!
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
14 | |
2 | |
2 | |
1 | |
1 |