Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Network Days excluding weekends and holidays

Hi Friends,

 

I read a nice post for calculating the aging or the network days excluding weekends and holidays. But the below DAX is hardcoded with a holiday date. I have a separate table with a list of holiday dates. I dont know how to use my holiday table inside this same query instead of the hardcoded date. Can you please help.

 

NetWorkDaysHolidays =
VAR Calendar1 = CALENDAR(MAX(NetWorkDays[created date]),MAX(NetWorkDays[review date]))
//VAR Holidays = DATATABLE("Date",DATETIME,{{}})
VAR Holidays1 = DATATABLE("Date",DATETIME,
{
{"12/25/2017 12:00:00 AM"}
})
VAR Calendar2 = EXCEPT(Calendar1,Holidays1)
VAR Calendar3 = ADDCOLUMNS(Calendar2,"WeekDay",WEEKDAY([Date],2))
RETURN COUNTX(FILTER(Calendar3,[WeekDay]<6),[Date])

  • Anonymous - Just use the name of your separate Holiday table. So if your table is called "My Holidays", your EXCEPT line would be:

     

    VAR Calendar2 = EXCEPT(Calendar1,'My Holidays')

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous - Just use the name of your separate Holiday table. So if your table is called "My Holidays", your EXCEPT line would be:

     

    VAR Calendar2 = EXCEPT(Calendar1,'My Holidays')

    • Anonymous's avatar
      Anonymous
      Not applicable

      Greg_Deckler  I think the solution is not working my live data. I have extracted the sample and tried the code. But the network days are completely showing as 1 for all the dates. I have the PBIX file in the below link. Can you please have a look.

       

      Also I am using max(CreatedDate) and Today() in the calendar line of the code. If I am using Max(createddate) and Max(ResolvedDate) it is throwing error message as Resolved Date column has blank or no dates for the open tickets. Is there any ideas to ignore or overcome this error if I use the ResovledDate column in the calendar line.

       

      https://1drv.ms/u/s!AuGvlNSP4ACnavfuTw7ZtV_n6G0?e=6Ee3mT