Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I am using the below function to determine working days but I need it to show 0 if the start date and complted date is the same. How can I do this?
= "(InitialDate as date, FinalDate as date ) as number => #(lf)let#(lf)DaysBetweenDates = Duration.Days(FinalDate-InitialDate),#(lf)DaysList = List.Dates(List.Min({InitialDate,FinalDate}),Number.Abs(DaysBetweenDates)+1, Duration.From(1)),#(lf)WeekDaysList = List.Select(DaysList, each (Date.DayOfWeek(_, Day.Monday) < 5) ),#(lf)WorkingDays = (if DaysBetweenDates < 0 then -1 else 1) * List.Count(WeekDaysList)#(lf)in#(lf)WorkingDays"
Solved! Go to Solution.
Hi @jslayer111
Change the query so that the last couple of lines are
#WorkingDays = (if DaysBetweenDates < 0 then -1 else 1) * List.Count(WeekDaysList),
Result = if InitialDate - FinalDate = 0 then 0 else #WorkingDays
in
Result
Regards
Phil
Proud to be a Super User!
Hi @jslayer111
Change the query so that the last couple of lines are
#WorkingDays = (if DaysBetweenDates < 0 then -1 else 1) * List.Count(WeekDaysList),
Result = if InitialDate - FinalDate = 0 then 0 else #WorkingDays
in
Result
Regards
Phil
Proud to be a Super User!