Power BI: DAX Function NETWORKDAYS
Power BI in July 2022 has released a new DAX function Networkdays.
I would like to explore the same here. I have uploaded the file used in this blog on GitHub. There are two tables. One with two dates to get networkdays and the second having US holidays for the Year 2022.
Networkdays function can take 4 parameters and the last two are optional
1. Start Date
2. End Date
3. Week End
4. Holidays
Power BI has given various weekend options, which you can find in the document. The common one is 1 which means the weekend is Saturday and Sunday
The traditional method to get the workdays between two dates was
Work Days Traditional 1 = Countrows(filter( CALENDAR([Date1],Dates[Date2]), WEEKDAY([Date],2) <6 ))
The same can be achieved using
Work Days 1 = NETWORKDAYS(Dates[Date1],Dates[Date2],1)
You can add holidays using the table, for example, manual table addition
Work Days 2 = NETWORKDAYS(Dates[Date1],Dates[Date2],1, {Date(2022,1,17)})
In the old method, you need to do
Work Days Traditional 2 = Countrows(filter( CALENDAR([Date1],Dates[Date2]), WEEKDAY([Date],2) <6 && not [Date] in {Date(2022,01,17)}))
You can use a calendar table, I will use the one I loaded into the file. I have more than one column. I am taking only one. I can use distinct to all.
Work Days = NETWORKDAYS(Dates[Date1],Dates[Date2],1, distinct(Holidays[Date]))
In the old method, you need to do
Work Days Traditional = Countrows(filter( CALENDAR([Date1],Dates[Date2]), WEEKDAY([Date],2) <6 && not [Date] in distinct(Holidays[Date])))
This is how it finally looks
You can find the file on Power BI Community. Like, Share, and Comment.
Please find the video on youtube
Old video on the same topics: How to calculate Business Days/ Workdays, with or without date table
Click Here to access all my blogs and videos in a jiffy via an exclusive visual glossary using Power BI.
Please like, share, and comment on these. Your suggestions on improvement, challenges, and new topics will help me explore more.
You Can watch my Power BI Tutorial Series on My Channel, Subscribe, Like, and share