To implement this recipe, perform the following steps:
- Create the following columns in the R07_Calendar table:
First Working Day of Week =
VAR __Date = 'R07_Calendar'[Date]
VAR __Calendar =
FILTER(
ADDCOLUMNS(
CALENDAR(__Date - 5 ,__Date + 5),
"__WeekNum",WEEKNUM('R07_Calendar'[Date]),
"__WeekDay",WEEKDAY('R07_Calendar'[Date], 2)
),
[__WeekDay] = 1
)
VAR __WorkingDay = MINX(__Calendar,'R07_Calendar'[Date])
RETURN __WorkingDay
First Working Day of Month =
VAR __Date = 'R07_Calendar'[Date]
VAR __Month = MONTH(__Date)
VAR __Year = YEAR(__Date)
VAR __Calendar =
FILTER(
ADDCOLUMNS(
CALENDAR(
DATE(__Year, __Month, 1),
DATE(__Year, __Month, DAY(EOMONTH(__Month,0)))
),
"__Month",MONTH('R07_Calendar'[Date]),
"__WeekDay",WEEKDAY('R07_Calendar'[Date], 2)
),
[__WeekDay] < 6
)
VAR __WorkingDay = MINX(__Calendar,'R07_Calendar'[Date])
RETURN __WorkingDay
- Create the following additional columns in the R07_Calendar table:
First Working Day of Quarter =
VAR __Date = 'R07_Calendar'[Date]
VAR __Quarter = ROUNDUP(MONTH([Date])/3,0)
VAR __Year = YEAR(__Date)
VAR __Calendar =
FILTER(
ADDCOLUMNS(
CALENDAR(
DATE(__Year, 1, 1),
DATE(__Year, 12, 31)
),
"__Quarter",ROUNDUP(MONTH('R07_Calendar'[Date])/3,0),
"__WeekDay",WEEKDAY('R07_Calendar'[Date], 2)
),
[__Quarter] = __Quarter &&
[__WeekDay] < 6
)
VAR __WorkingDay = MINX(__Calendar,'R07_Calendar'[Date])
RETURN __WorkingDay
First Working Day of Year =
VAR __Date = 'R07_Calendar'[Date]
VAR __Year = YEAR(__Date)
VAR __Calendar =
FILTER(
ADDCOLUMNS(
CALENDAR(
DATE(__Year, 1, 1),
DATE(__Year, 12, 31)
),
"__WeekDay",WEEKDAY('R07_Calendar'[Date], 2)
),
[__WeekDay] < 6
)
VAR __WorkingDay = MINX(__Calendar,'R07_Calendar'[Date])
RETURN __WorkingDay