From c6ceceee74e3ce925ddfc0c33c30adea12a6d56e Mon Sep 17 00:00:00 2001 From: Alberto Spelta Date: Tue, 26 Mar 2024 14:30:12 +0100 Subject: [PATCH 1/2] Fix configuration error when WeekDayNumber is 0 (Sunday) --- src/Dax.Template/Tables/Dates/HolidaysTable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dax.Template/Tables/Dates/HolidaysTable.cs b/src/Dax.Template/Tables/Dates/HolidaysTable.cs index 657b80d..02290a5 100644 --- a/src/Dax.Template/Tables/Dates/HolidaysTable.cs +++ b/src/Dax.Template/Tables/Dates/HolidaysTable.cs @@ -129,7 +129,7 @@ public HolidaysTable(IHolidaysConfig config): base(config) __SeptemberEquinox + '{config.HolidaysDefinitionTable}'[DayNumber], IF ( '{config.HolidaysDefinitionTable}'[MonthNumber] = 96, -- March Equinox __MarchEquinox + '{config.HolidaysDefinitionTable}'[DayNumber], - IF ( '{config.HolidaysDefinitionTable}'[WeekDayNumber] <> 0, + IF ( '{config.HolidaysDefinitionTable}'[WeekDayNumber] IN {{ 0, 1, 2, 3, 4, 5, 6 }}, VAR _ReferenceDate = DATE ( __HolidayYear, 1 + MOD ( '{config.HolidaysDefinitionTable}'[MonthNumber] - 1 + IF ( '{config.HolidaysDefinitionTable}'[OffsetWeek] < 0, 1 ), 12 ), 1 ) From 3b136ead9c793c72cf0b0aa1d0d2c91948c726cd Mon Sep 17 00:00:00 2001 From: Alberto Spelta Date: Tue, 9 Apr 2024 20:33:22 +0200 Subject: [PATCH 2/2] Applied fix as suggested by the code review --- src/Dax.Template/Tables/Dates/HolidaysTable.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Dax.Template/Tables/Dates/HolidaysTable.cs b/src/Dax.Template/Tables/Dates/HolidaysTable.cs index 02290a5..d6c0dd3 100644 --- a/src/Dax.Template/Tables/Dates/HolidaysTable.cs +++ b/src/Dax.Template/Tables/Dates/HolidaysTable.cs @@ -129,7 +129,10 @@ public HolidaysTable(IHolidaysConfig config): base(config) __SeptemberEquinox + '{config.HolidaysDefinitionTable}'[DayNumber], IF ( '{config.HolidaysDefinitionTable}'[MonthNumber] = 96, -- March Equinox __MarchEquinox + '{config.HolidaysDefinitionTable}'[DayNumber], - IF ( '{config.HolidaysDefinitionTable}'[WeekDayNumber] IN {{ 0, 1, 2, 3, 4, 5, 6 }}, + IF ( '{config.HolidaysDefinitionTable}'[WeekDayNumber] IN {{ 0, 1, 2, 3, 4, 5, 6 }} + && '{config.HolidaysDefinitionTable}'[DayNumber] = 0 + && '{config.HolidaysDefinitionTable}'[OffsetWeek] <> 0 + && '{config.HolidaysDefinitionTable}'[MonthNumber] IN {{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }}, VAR _ReferenceDate = DATE ( __HolidayYear, 1 + MOD ( '{config.HolidaysDefinitionTable}'[MonthNumber] - 1 + IF ( '{config.HolidaysDefinitionTable}'[OffsetWeek] < 0, 1 ), 12 ), 1 )