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

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
Employee
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
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.