Forum Discussion

Eagles83's avatar
Eagles83
New Member
9 years ago
Solved

WORKDAY formula in Power BI

I want to count 3 business days from [dateX]   The result must exclude weekends and federal holidays. The Excel equivalent would be WORKDAY(dateX,3,'Federal Holiday Sheet'!A;A))  with the Federal Hol...
  • Anonymous's avatar
    Anonymous
    9 years ago

    Eagles83,

    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,