Forum Discussion
Incorrect week number 2020/2021
Hello.
I am quite new to Power BI and I have leveraged a lot of knowledge from this forum so far but now I need help from you guys if possible.
I am currently experiencing a problem where Power BI does not show correct week numbers since we switched from the year 2020 to 2021. This is the current behaviour that I get in terms of week numbers:
W01 - starts on 01/01/2021
W02 - starts on 04/01/2021
W03 - starts on 11/01/2021
...
While it should be like the following:
W01 - starts on 04/01/2021
W02 - starts on 11/01/2021
W03 - starts on 18/01/2021
...
Since I am working a lot with relative weeks/months/quarters when visualising things, this is the formula that is used to calculalculate the week number:
= Table.AddColumn( #"Added rDate", "Week", each " W" & Text.PadStart( Number.ToText( Date.WeekOfYear( [Date] ) ), 2, "0" ), type text )
EDIT: My first day of the week is Monday.
Can someone please help me solve this problem? Thank you!
I managed to get this working by following this tutorial:
http://datacornering.com/how-to-calculate-iso-week-number-in-power-query/
6 Replies
- parry2k
Super User
n5722 what is your first day of week, read this documentation.
= Table.AddColumn( #"Added rDate", "Week", each " W" & Text.PadStart( Number.ToText( Date.WeekOfYear( [Date], Day.Sunday ) ), 2, "0" ), type text )Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- parry2k
Super User
n5722 change the M code from Day.Sunday to Day.Monday
Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- MacarenaGB
Helper II
Hi, check this:
CalendarWeek = ROUNDDOWN(([DateKey]-DATE(year([DateKey]-WEEKDAY([DateKey]-1)+4),1,3)+WEEKDAY(DATE(YEAR([DateKey]-WEEKDAY([DateKey]-1)+4),1,3))+5)/7,0)
Source:https://powerbiuniversity.com/calendario-completo-dax/ - n5722
Helper I
I managed to get this working by following this tutorial:
http://datacornering.com/how-to-calculate-iso-week-number-in-power-query/