How to Use the NETWORKDAYS DAX Function in Power BI
In this blog, we’ll explore how to use the NETWORKDAYS DAX function in Power BI to calculate the number of working days between two dates, excluding weekends and optionally specified holidays.
What is the NETWORKDAYS Function?
The NETWORKDAYS function in Power BI's DAX language helps calculate business days by excluding weekends and specified holidays from the total days between two dates.
Syntax: NETWORKDAYS(<start_date>, <end_date>[, <weekend>, <holidays>])
Steps to Implement NETWORKDAYS in Power BI
Step 1: Create a Table Visual
- Select the Table visual.
- Drag the following fields from the dataset into the Values section:
OrderID
OrderDate
ShippedDate
HolidayList (preloaded with holiday dates).
Step 2: Create a Measure for Working Days
Write the DAX measure using the NETWORKDAYS function:
No. of working days =
VAR start_date = SELECTEDVALUE(Orders[OrderDate])
VAR end_date = SELECTEDVALUE(Orders[ShippedDate])
RETURN
NETWORKDAYS(start_date, end_date, 1, HolidayList[HolidayDate])
Note: Ensure the holiday list is loaded as a table in your Power BI model, as the holidays parameter requires a column reference.
Step 3: Add the Measure to the Table Visual
Drag the No. of working days measure into the Table visual.
The output will display the number of business days (excluding weekends and specified holidays) between the order and shipment dates for each record.
Conclusion
The NETWORKDAYS DAX function simplifies calculating business days, making it a valuable tool for time-sensitive metrics such as delivery times, project schedules, or workforce planning.
Best Regards
Anmol Malviya
Data Analyst | Addend Analytics
Comments
Post a Comment