Forum Discussion
WORKDAY formula in Power BI
- Anonymous9 years ago
Firstly, import your Federal Holiday sheet and data table to Power BI Desktop.
Secondly, create a calendar table using calendar() function, create relationship between data table and calendar table using date field, and create relationship between Federal Holiday table and calendar table using date field, here is an example for you.
Thirdly, create the following calculated columns in the calendar table.
WeekDay = WEEKDAY('Calendar'[Date])
Holiday = RELATED('Federal Holiday'[Holiday])
If work day = IF(OR('Calendar'[WeekDay]=1,'Calendar'[WeekDay]=7),0,IF(ISBLANK('Calendar'[Holiday]),1,0))
Rank = RANKX(FILTER('Calendar','Calendar'[If work day]=1),'Calendar'[Date],,ASC)
Add 3 businss days = LOOKUPVALUE('Calendar'[Date],'Calendar'[If work day],1,'Calendar'[Rank],'Calendar'[Rank]+3)At last, create a calculated column using the following DAX in your data table.
Column = RELATED('Calendar'[Add 3 businss days])
Regards,
This was very helpful. Can you please clarify which 'Date' in your response represents my "DateX" in my question? I'm not sure if my DateX is the Date if the Fact Table for the Date in the Calendar table.
It's possible to calculate workdays without a Date table with the following Measure or Calculated Column in DAX: