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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Weeks (52-53) over multiple years.

Weeks 52 and 53 have the potential to be spilt over 2 calender years.

 

Week 52 for example starts on 27th December 2021 and ends on the 2nd of January 2022.

 

Hence when i use Week Number as a x axis and filter the visual by Year 2021 week 52 appears on the right (end) of the x-axis like it should.

 

However if i filter by 2022 week 52 still  appears at the right (end) of the x-axis. In this situation you would expect it to appear on the left (the start_ of the x-axis as technically it incorporates the 1st and 2nd of Janaury 2022.

 

I found this post similar and the x-axis on their visual looks rather neat Solved: Graph showing x-weeks rolling data over multiple y... - Microsoft Power BI Community.

 

Sadly i couldnt get it to work on my pbix file (problably as im using a different visual and multiple values) 

 

How do i recreate my visual to show the x-axis like the link above OR simply have the week numbers correspond to the Years Correctly

 

 

Pbix Sample 

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

I updated your sample pbix file(see attachment), please check whether that is what you want.

1. Create a calculated column as below in Calendar table

YearWeek = 
VAR _week =
    IF (
        'Calendar'[WEEKOFYEAR] < 10,
        "0" & 'Calendar'[WEEKOFYEAR],
        'Calendar'[WEEKOFYEAR]
    )
RETURN
    IF (
        'Calendar'[MONTH] = 1
            && 'Calendar'[WEEKOFYEAR] > 50,
        ( 'Calendar'[YEAR] - 1 ) & _week,
        'Calendar'[YEAR] & _week
    )

yingyinr_0-1650936187326.png

2. Replace the field "WEEKOFYEAR" in X axis of chart with the new calculated column just as shown in below screenshot

yingyinr_1-1650936310538.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Im accepting the solution as it functionaly does what i ask (i.e. put weeks in the right order according to the year), one minor issue is how it looks on the report but client is willing to accept 

v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

I updated your sample pbix file(see attachment), please check whether that is what you want.

1. Create a calculated column as below in Calendar table

YearWeek = 
VAR _week =
    IF (
        'Calendar'[WEEKOFYEAR] < 10,
        "0" & 'Calendar'[WEEKOFYEAR],
        'Calendar'[WEEKOFYEAR]
    )
RETURN
    IF (
        'Calendar'[MONTH] = 1
            && 'Calendar'[WEEKOFYEAR] > 50,
        ( 'Calendar'[YEAR] - 1 ) & _week,
        'Calendar'[YEAR] & _week
    )

yingyinr_0-1650936187326.png

2. Replace the field "WEEKOFYEAR" in X axis of chart with the new calculated column just as shown in below screenshot

yingyinr_1-1650936310538.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thannks @johnt75 Attempting to do what you suggest: brings up this prompt ISOWEEKKEY is the YYYYWW column

 

Sort by Column ErrorSort by Column Error

johnt75
Super User
Super User

You could create a new column on your date table with year and week number combined like YYYYWW and then use that as the sort column for Week Number.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.