Forum Discussion
Anonymous
5 years agoNot applicable
WEEKNUM returns false calendar weeks
Hello, I am facing the following issue: I am trying to calculate the calendar weeks with WEEKNUM() and have the following errors with the two different variants of the function: -Calendarweek...
- 5 years ago
Anonymous - I found a formula for ISO Year from a previous post. This should get you what you want.
CalendarWeek = VAR __Wk = WEEKNUM ( DateTab[Date], 21 ) VAR __ISOYr = IF ( AND ( WEEKNUM ( DateTab[Date], 21 ) < 5, WEEKNUM ( DateTab[Date], 2 ) > 50 ), DateTab[Year] + 1, IF ( AND ( WEEKNUM ( DateTab[Date], 21 ) > 50, WEEKNUM ( DateTab[Date], 2 ) < 5 ), DateTab[Year] - 1, DateTab[Year] ) ) RETURN __ISOYr & "-" & __WkHope this helps
David
dedelman_clng
Community Champion
5 years agoHi Anonymous -
Using WEEKNUM without a second value (as in your first attempt) defaults to Sunday as the first day of the week.
Try WEEKNUM([date], 2) for weeks beginning on a Monday.
There is some explanation behind the use of 21 at this link: https://dax.guide/weeknum/
Hope this helps
David
- Anonymous5 years agoNot applicable
Hi David,
Thank you for replying and your help!
Unfortunately it still returns 2021-3 for the current week.
How should I proceed?
Thank you in advance!