sql-bi / DaxDateTemplate

Power BI template to create a Date table in DAX
MIT License
265 stars 76 forks source link

Weeknumbers #48

Closed JLervad closed 3 years ago

JLervad commented 3 years ago

I recently found this project, and it works wonders. Now, I am having trouble with 2021 where 1/1-2021 is marked as Calendar Week 1 instead of Calendar Week 53 of 2020, and 4/1-2021 is marked as Calendar Week 2 and so on.

I can't seem to find the right combination of settings to get the week numbers that I would like. Am I misunderstanding how the field Calendar Week should/could be flexible?

Current Output: Date Calendar Week
28-12-2020 W53
29-12-2020 W53
30-12-2020 W53
31-12-2020 W53
01-01-2021 W01
02-01-2021 W01
03-01-2021 W01
04-01-2021 W02
05-01-2021 W02
Wanted output: Date Calendar Week
28-12-2020 W53
29-12-2020 W53
30-12-2020 W53
31-12-2020 W53
01-01-2021 W53
02-01-2021 W53
03-01-2021 W53
04-01-2021 W01
05-01-2021 W01

Current settings in PBIX file:

VAR FirstYear = 2019
VAR LastYear = 
    YEAR ( TodayReference )
VAR FiscalCalendarFirstMonth = 1 -- For Fiscal 52-53 weeks (start depends on rules) and Gregorian (starts on the first of the month) 
VAR FirstDayOfWeek = 1 -- Use: 0 - Sunday, 1 - Monday, 2 - Tuesday, ... 5 - Friday, 6 - Saturday
VAR TypeStartFiscalYear = 1 -- Fiscal year as Calendar Year of : 0 - First day of fiscal year, 1 - Last day of fiscal year
VAR IsoCountryHolidays = "US" -- Use only supported ISO countries or "" for no holidays
VAR WeeklyType = "Nearest" -- Use: "Nearest" or "Last" 
VAR QuarterWeekType = "445" -- Supports only "445", "454", and "544"
VAR CalendarRange = "FiscalGregorian" -- Supports "Calendar", "FiscalGregorian", "FiscalWeekly"
marcosqlbi commented 3 years ago

You should use the FW Calendar Week column for a week-based calendar. The Calendar prefixed columns strictly follow the Gregorian calendar boundaries. Let me know if this clarifies so I can close the issue. Thanks!

JLervad commented 3 years ago

Thank you for the clarification Marco. We will use FW.