Forum Discussion
Weeknum wrong
I'm sorry i wasn't clear. Let my try to elaborate.
Currently, DAX code 'weeknum(date;1)' shows that week 1 starts on Jan 1st and week 2 starts on Jan 3rd of 2021. While Jan 1st is a friday, making that particular week both week 53 AND 1. Which should not even be possible to begin with. (why else define where the week starts, if the code is going to completely neglect it anyway)
So not only does it count week 2 wrong, it starts counting week 1 halfway a week, totally neglecting the startday of a week. Which really tells me that it is actually basing the weekcount based on the year and not actually a date time format.
The question is now. How is it even possible that weeknum cuts a week in half and decides to give it 2 values? The followup question would be, how can we fix that, structurally?
The third question would be, what would be a proper DAX code without an IF statement to correct each and every year seperately, that we / i can use to correctly display week numbers?
decarsul , I think power bi changes week with year, so your week 52/53 or week 1 can smaller weeks.
In case you do not need that you might have build custom calendar (Date table)