Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
AnnaML
Frequent Visitor

Week number not matching date

Hello, 

 

I have an issue with week numbers. I have created a column called YearWeek using the following: 

YearWeek = IF(WEEKNUM([Date].[Date])<10,FORMAT([Date],"YY0WW"),FORMAT([Date],"YYWW"))
 
I put date and yearweek into a table and got the following:
 
 
 

yearweek.png

My issues is that the weeks does not match the right dates. For example in this table it shows that week 3 is between 10-16 of January but in reality it's between 17-24 January. I want week 1 to start with January 3rd. 

Can someone please help me? 

 

Thankful for support, 

1 ACCEPTED SOLUTION

@AnnaML 

 

Try this formula:

 

YearWeek = RIGHT(IF(WEEKNUM('Calendar'[Date], 21)=53 && MONTH('Calendar'[Date])=1, YEAR('Calendar'[Date]) -1, YEAR('Calendar'[Date])),2) & WEEKNUM('Calendar'[Date], 21)

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hello, how about if I want the week number only, WW?

Thank you.

themistoklis
Community Champion
Community Champion

@AnnaML 

 

If you want to use a Iso YEAR Week the formula should be like this:

YearWeek = IF(WEEKNUM('Calendar'[Date], 21)=53 && MONTH('Calendar'[Date])=1, YEAR('Calendar'[Date]) -1, YEAR('Calendar'[Date])) & "-" & WEEKNUM('Calendar'[Date], 21)

 

You need to put another parameter in weeknum function.... the parameter with value 21.

See also link below:

https://community.powerbi.com/t5/Desktop/Looking-for-real-year-week/m-p/1591530#M646306

 

 

Hello, 

Thanks for your answere. It seems to work. Although is it possible to show YYWW instead of YYYY-WW? 

Kind Regards

@AnnaML 

 

Try this formula:

 

YearWeek = RIGHT(IF(WEEKNUM('Calendar'[Date], 21)=53 && MONTH('Calendar'[Date])=1, YEAR('Calendar'[Date]) -1, YEAR('Calendar'[Date])),2) & WEEKNUM('Calendar'[Date], 21)

Thanks for the support, it really helped! 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.