Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BI_Analyticz
Helper V
Helper V

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
Greg_Deckler
Super User
Super User

@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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.