Forum Discussion
sw123
4 years agoHelper III
Problems with week number
Hi,
I have a date table with a week year column like this:
"Week year", YEAR([Date]) & " "& WEEKNUM([Date], 21)
In our calender (ISO 8601) Januari 1st and 2nd 2022 is part of week 52 2021. My date calender sets Januari 1st and 2nd to week 52 2022, which is of course totally wrong. How can I fix this?
Thanx in advance!
Hi sw123 ,
Try this:-
Column = VAR week_num = 1+ INT ( DIVIDE ( ( [Date] - WEEKDAY ( [Date], 16 ) + 1 ) - ( DATE ( YEAR ( [Date] ), 1, 1 ) ), 7 ) ) RETURN "Week year " & YEAR ( [Date] ) & " " & week_numThanks,
Samarth
2 Replies
- Samarth_18Community Champion
Hi sw123 ,
Try this:-
Column = VAR week_num = 1+ INT ( DIVIDE ( ( [Date] - WEEKDAY ( [Date], 16 ) + 1 ) - ( DATE ( YEAR ( [Date] ), 1, 1 ) ), 7 ) ) RETURN "Week year " & YEAR ( [Date] ) & " " & week_numThanks,
Samarth
- ALLUREANSolution Sage
Hi, sw123
Try this calendar dax script (you need to play with the iso parameters also):
https://www.dropbox.com/s/qo20q59mbsz60av/Custom%20Calendar%20%28ISO%2C%20445%2C%20etc%29.txt?dl=0
or this can be also helpful:
https://blog.gbrueckl.at/2012/04/iso-8601-week-in-dax/