Forum Discussion
Week Number calculation DAX query returning wrong results
- 5 years ago
I solved the issue but in different way.I am writing the solution so that anyone else can refer in the coming days .Instead of 2 use 21 as parameter.
WeekNumber = WEEKNUM([Date],21)
This will fetch correct results
Use the second argument to control the starting day of the week:
WeekNumber = WEEKNUM([Date], 2)
Hi DataInsights
Interesting information, i tried to add the parameter 2 but it still returned the same old results.
The week number is 21 instead of 20 from 17 May to 23 May 2021.
The week 1 of the year 2021 starts from 4th Jan to 10th Jan since 28 December 2020 to 3rd Jan 2021 is week number 52(or last week of the year 2020) of the year 2020.
so the first week of 2021 should start from 4th Jan which is a Monday. Could you please suggest where am I missing. If possible could you please use the source input i have provided in the above thread , you will also get the same error I am getting.
This week 17 May - 23 May is week number 20 but it shows week number 21.
- DataInsights5 years agoSuper User
It's a difference in how the first week of the year is handled. See the screenshot below:
The first week of January starts on Friday, so week 1 is a partial week. It sounds as if you want to define week 1 as the first week that contains a Monday. If so, you would have to create additional logic to handle this scenario.
- deb_power1235 years agoHelper V
I solved the issue but in different way.I am writing the solution so that anyone else can refer in the coming days .Instead of 2 use 21 as parameter.
WeekNumber = WEEKNUM([Date],21)
This will fetch correct results