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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Help with creating automated rolling week

Hi guys. Hoping you can help me with this query, I have been looking and haven't seen a solution yet.

So I have a database that includes, among others, a colour for Year (can be 2018 or 2019) and Week. For 2018 I have 53 weeks, and 2019 is being updated every week so every week there is a new week being added. I need to compare weekly same period of 2018 and 2019 for several metrics. So this week I am comparing sales for week 20 in 2018 and week 20 in 2019, as well as week 1 to week 20 in 2018 and 2019.

As I mentioned this is updated weekly, and I would like to avoid filtering manually on a weekly basis, I would like to automate it as much as possible.

How do I create a metric/column that helps me filter same week for 2018 and same period for 2018 (week 1 to last available week, as this will vary weekly).

 

Hope I'm being clear, apologies if not!

1 ACCEPTED SOLUTION

Hi @Anonymous 

You could create the second measure as below:

sales_ 2018 = 
CALCULATE (
    SUM ( Table1[Sales] ),
    FILTER (
        ALL ( Table1 ),
        Table1[Year]
            = MAX ( Table1[Year] ) - 1
            && Table1[Week]
                >= MAX ( Table1[Week] ) - 4
            && Table1[Week] <= MAX ( Table1[Week] )
    )
)

Regards,

Community Support Team _ Cherie Chen
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

3 REPLIES 3
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous 

You may refer to below measure.It could get the rolling week sum for 5 weeks for 2019.For example:

2019_sales = 
IF (
    MAX ( Table1[Year] ) = 2019,
    CALCULATE (
        SUM ( Table1[Sales] ),
        FILTER (
            ALL ( Table1 ),
            Table1[Year] = 2019
                && Table1[Week]
                    >= MAX ( Table1[Week] ) - 4
                && Table1[Week] <= MAX ( Table1[Week] )
        )
    )
)

1.png

Regards,

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

Thanks - this is helpful and helps me calculate it for 2019. However, it doesn't allow me to calculate it for the previous year (same period) for comparison?

 

Hi @Anonymous 

You could create the second measure as below:

sales_ 2018 = 
CALCULATE (
    SUM ( Table1[Sales] ),
    FILTER (
        ALL ( Table1 ),
        Table1[Year]
            = MAX ( Table1[Year] ) - 1
            && Table1[Week]
                >= MAX ( Table1[Week] ) - 4
            && Table1[Week] <= MAX ( Table1[Week] )
    )
)

Regards,

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

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors
Top Kudoed Authors