Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi, I apologize in advance for the verbose question.
I have a table with Start_Date and End_Date and values for 4 services. I need to create a list to obtain daily values based on work dates to include holidays.
I created a calculated table in powerbi that works perfectly, but i am not able to merge the information in power query with other existing tables so i am trying to create in power query. The code i used to create the calculated table (and the non-working day column in my powerbi date table) is below. I have created a list in power query of the dates between the start and stop date, but i need to remove the dates from the calculation that are not work dates (sat, sun, holiday) preferably built into the code, not having to create a separate holiday table.
__________________________________________
Solved! Go to Solution.
my solution, but if anything can improve, please let me know:
I created a networkdays function then created a list to expand the dates, it covers the weekends, but not the holidays. I used the same function to determine the network days to determine the daily values -->
______________________________________
Function -->
= (StartDate as date, EndDate as date) as number =>
let
DateList = List.Dates(StartDate, Number.From(EndDate - StartDate), #duration(1,0,0,0)),
RemoveWeekends = List.Select(DateList, each Date.DayOfWeek(_, Day.Monday) < 5),
CountDays = List.Count(RemoveWeekends)
in
CountDays
_________________________________
= Table.AddColumn(#"Changed Type1", "Dates_Test", each let
AllDates = {Number.From([DA_EXPECTED_START_DATE])..Number.From([DA_EXPECTED_END_DATE])},
StartDate =
List.Transform(AllDates, each Date.From(_)) in StartDate)
my solution, but if anything can improve, please let me know:
I created a networkdays function then created a list to expand the dates, it covers the weekends, but not the holidays. I used the same function to determine the network days to determine the daily values -->
______________________________________
Function -->
= (StartDate as date, EndDate as date) as number =>
let
DateList = List.Dates(StartDate, Number.From(EndDate - StartDate), #duration(1,0,0,0)),
RemoveWeekends = List.Select(DateList, each Date.DayOfWeek(_, Day.Monday) < 5),
CountDays = List.Count(RemoveWeekends)
in
CountDays
_________________________________
= Table.AddColumn(#"Changed Type1", "Dates_Test", each let
AllDates = {Number.From([DA_EXPECTED_START_DATE])..Number.From([DA_EXPECTED_END_DATE])},
StartDate =
List.Transform(AllDates, each Date.From(_)) in StartDate)