I am trying to create a custom function which calculates the workday difference between two dates. I have done the same function in SSRS:
Public Function WorkdayDiff(StartDate As Date, EndDate As Date) As Date
Return Datediff("ww", StartDate, EndDate, vbMonday) +
Datediff("ww", StartDate, EndDate, vbTuesday) +
Datediff("ww", StartDate, EndDate, vbWednesday) +
Datediff("ww", StartDate, EndDate, vbThursday) +
Datediff("ww", StartDate, EndDate, vbFriday)
End Function
I tryed to do the same now in Power Query M language but it keeps me saying:
Type is not defined.
This is my code in the advanced editor in Power BI:
(DateStart as Date, DateEnd as Date) as Date =>
let
WorkdayDiff = Datediff("ww",DateStart ,DateEnd, vbMonday) +
Datediff("ww",DateStart ,DateEnd, vbTuesday) +
Datediff("ww",DateStart ,DateEnd, vbWednesday) +
Datediff("ww",DateStart ,DateEnd, vbThursday) +
Datediff("ww",DateStart ,DateEnd, vbFriday)
in
WorkdayDiff