cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper III
Helper III

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])

1 ACCEPTED SOLUTION

Accepted Solutions
Super User IV
Super User IV

@BI_Analyticz - 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')


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Super User IV
Super User IV

@BI_Analyticz - 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')


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

@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 

Helpful resources

Announcements
November Update

Check it Out!

Click here to read more about the November 2020 Updates!

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform October Community Highlights

Check out the top community contributors across all of the communities

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors