Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SubstituteHoliday to match WorkingDays range [2..6] #49

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Dax.Template/Tables/Dates/HolidaysTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ public HolidaysTable(IHolidaysConfig config): base(config)
ERROR ( ""Wrong configuration in {config.HolidaysDefinitionTable}"" )
) ) ) ) ) ) )
// )
VAR __HolidayDay = WEEKDAY ( __HolidayDate, 1 ) - 1
VAR __HolidayDay = WEEKDAY ( __HolidayDate, 1 )
VAR __SubstituteHolidayOffset =
// SWITCH (
// TRUE,
IF ( '{config.HolidaysDefinitionTable}'[SubstituteHoliday] = -1,
SWITCH (
__HolidayDay,
0, 1, -- If it falls on a Sunday then it is observed on Monday
6, -1, -- If it falls on a Saturday then it is observed on Friday
1, 1, -- If it falls on a Sunday then it is observed on Monday
7, -1, -- If it falls on a Saturday then it is observed on Friday
0
),
IF ( '{config.HolidaysDefinitionTable}'[SubstituteHoliday] > 0
Expand Down Expand Up @@ -259,7 +259,7 @@ RETURN ROW (
VAR _SubstituteOffsetStep1 = [@SubstituteHolidayOffset] + _ConflictDay0 + _ConflictDay1 + _ConflictDay2
VAR _HolidayDateStep1 = _CurrentHolidayDate + _SubstituteOffsetStep1
VAR _HolidayDayStep1 =
WEEKDAY ( _HolidayDateStep1, 1 ) - 1
WEEKDAY ( _HolidayDateStep1, 1 )
VAR _SubstituteHolidayOffsetNonWorkingDays =
IF (
NOT CONTAINS ( __WorkingDays, ''[Value], _HolidayDayStep1 ),
Expand All @@ -274,7 +274,7 @@ NOT CONTAINS ( __WorkingDays, ''[Value], _HolidayDayStep1 ),
MINX ( __WorkingDays, ''[Value] ) + 7,
_NextWorkingDayStep2
)
RETURN _SubstituteDay - _HolidayDateStep1
RETURN _SubstituteDay - _HolidayDayStep1
)
VAR _SubstituteOffsetStep2 = _SubstituteOffsetStep1 + _SubstituteHolidayOffsetNonWorkingDays
VAR _SubstituteDateStep2 = _OriginalSubstituteDate + _SubstituteOffsetStep2
Expand Down
Loading