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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mrclay823
New Member

Rolling 52 weeks.

Hi all,

 

I want to create this visual in PBI for our [sales] measure (pretend that w.2 is last week and for 52 weeks.

 

So, one line to show the sales rolling 52 weeks and one to show the same period the year before.

 

Can you please advise? I have a week column in my date table which is a whole number and a YearWeek column which is stored as text. No changes can be made to the formats and I am not allowed to create any new columns.

mrclay823_1-1738325507563.png

 

Thanks!

 

 

 

7 REPLIES 7
techies
Super User
Super User

Hi @mrclay823 Rolling 52 Weeks Sales =
CALCULATE(
    [sales],  
    DATESINPERIOD(
        'Date'[Date],
        MAX('Date'[Date]),
        -365,  
        DAY
    ),
    VALUES('Date'[Weeknum])  
)
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978
techies
Super User
Super User

Rolling 52 Weeks Sales =
CALCULATE(
    [sales],  
    DATESINPERIOD(
        'Date'[Date],
        MAX('Date'[Date]),
        -365,  
        DAY
    ),
    VALUES('Date'[Weeknum])  
)
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978
Poojara_D12
Super User
Super User

Hi @mrclay823 

To create this rolling 52-week comparison visual in Power BI with one line for the last 52 weeks and another for the same period the previous year, you can use DAX measures. Since you cannot modify column formats or create new columns, we will work with measures only.

 

This measure will sum the sales for the last 52 weeks dynamically:

Sales Rolling 52 Weeks =
VAR MaxWeek = MAX('Date'[Week])  -- Get the latest selected week
VAR MaxYearWeek = MAX('Date'[YearWeek]) -- Get the latest YearWeek in context
RETURN
CALCULATE(
    SUM(Sales[SalesAmount]), 
    'Date'[YearWeek] <= MaxYearWeek && 
    'Date'[YearWeek] > MaxYearWeek - 52 -- Include the last 52 weeks
)

 

 

To compare the same period from the previous year, shift the YearWeek by 52 weeks back:

Sales Rolling 52 Weeks LY =
VAR MaxWeek = MAX('Date'[Week])  
VAR MaxYearWeek = MAX('Date'[YearWeek])  
RETURN
CALCULATE(
    SUM(Sales[SalesAmount]), 
    'Date'[YearWeek] <= MaxYearWeek - 52 &&
    'Date'[YearWeek] > MaxYearWeek - 104  -- Shift 52 weeks back
)

 

 

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

Hey @Poojara_D12 and thanks!

I am stuck on the first measure:

mrclay823_0-1738573968478.png

 

bhanu_gautam
Super User
Super User

@mrclay823 , Create Measures for Rolling 52 Weeks Sales:

Rolling52WeeksSales =
CALCULATE(
SUM(Sales[SalesAmount]),
DATESINPERIOD(
DateTable[Date],
MAX(DateTable[Date]),
-52,
WEEK
)
)

 

Create Measures for the Same Period Last Year:

Rolling52WeeksSalesLastYear =
CALCULATE(
[Rolling52WeeksSales],
SAMEPERIODLASTYEAR(DateTable[Date])
)

 

Add the DateTable[Date] to the axis.
Add the Rolling52WeeksSales measure to the values.
Add the Rolling52WeeksSalesLastYear measure to the values.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hi,

mrclay823_0-1738574219262.png

 

Hi there @mrclay823 

 

Have you tried this?

Rolling 52 Weeks Sales =
CALCULATE(
    [sales],
    FILTER(
        ALLSELECTED('date'),         
YEAR('date'[Date]) = YEAR(MAX('date'[Date])) &&  
        'date'[Weeknum] <= WEEKNUM(MAX('date'[Date])) &&  
        'date'[Weeknum] > WEEKNUM(MAX('date'[Date])) - 52  
    ),
    ALLEXCEPT('date', 'date'[Year])  
)
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.