various shenanigans.

DAX: Add Business Days to Date

DAX calculated column code to add business days or network days to a date.

VAR __Date = IF(Table1[StartDate] <> BLANK(), Table1[StartDate], date(2000, 1, 1))

// Days to Add; in my use case, the # of days was dependent on a category value. You can just set this a specific number if applicable

VAR __Days = SWITCH(TRUE(),

  [Category] = “Complex”, 43,

  [Category] = “Moderate”, 31,

  [Category] = “Simple”, 29,

    )

// This var creates a temp calendar padded out by the *3

VAR __Calendar = ADDCOLUMNS(CALENDAR(__Date, __Date + (__Days) * 3), “Weekday” , WEEKDAY([Date],2))

// filter out the weekends

VAR __CalendarX = FILTER(__Calendar, [Weekday] < 6)

// add an addition column to the temp calendar that counts the # of days needed.

 VAR __CalendarY = ADDCOLUMNS(__CalendarX,  “Days”, COUNTROWS(FILTER(__CalendarX, [Date] <= EARLIER([Date]))

    )

 )

RETURN

// returns the new ‘due’ date that is __Days out from the StartDate.

   SELECTCOLUMNS(FILTER(__CalendarY, [Days] = __Days), “Date”, [Date])

Close Bitnami banner
Bitnami