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

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

Reply
rsbin
Super User
Super User

Week on Week comparison in a Clustered Column Chart

Good Afternoon,

 

I am using a Clustered Column Chart to create a Week by Week comparison for 2020 vs 2019.  Dataset starts at Jan 1, 2019

I have WeekNumber on the X-axis and Year in my Legend.  I would only like to show a rolling 13 weeks time series.

 

So far I can show the last 13 weeks for 2020 by Filtering on Top 13 of Year-WeekNum.

I have also created a Week Rank and filtered on the Top 13 weeks (kudos to @amitchandak for the idea on Rank), thinking I can somehow work with this.

rsbin_0-1597779515498.png

I am drawing blanks on how to grab the same 13 weeks for the Prior Year (2019) ???

Thoughts and suggestions are much appreciated.

 

Best Regards to All,

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Assuming you have a Date table with a WeekNumber column, you should be able to use a measure like this that should give nonblank/shown values for the last 13 weeks.

 

NewMeasure =
VAR thisweek =
    WEEKNUM ( TODAY () )
RETURN
    CALCULATE (
        [Your Measure],
        KEEPFILTERS (
            FILTER (
                ALL ( 'Date'[WeekNumber] ),
                'Date'[WeekNumber] <= thisweek
                    && 'Date'[WeekNumber] >= thisweek - 12
            )
        )
    )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





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

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
v-xicai
Community Support
Community Support

Hi @rsbin ,

 

You may create Week of Year column , and two rolling 13 week measures like DAX below.

 

 

 

Column:

Week of Year = WEEKNUM(Table1[Date])




Measure:


Rolling 13 Weeks Current Year =
VAR i= SELECTEDVALUE(Table1[Week])
RETURN
CALCULATE (SUM ( Table1[Sales] ),FILTER ( ALLSELECTED(Table1), YEAR(Table1[Date])= YEAR(MAX(Table1[Date]))&&Table1[Week] <= i + 12 && Table1[Week] >= i ) )


Rolling 13 Weeks Previous Year =
VAR i= SELECTEDVALUE(Table1[Week])
RETURN
CALCULATE (SUM ( Table1[Sales] ),FILTER ( ALLSELECTED(Table1), YEAR(Table1[Date])= YEAR(MAX(Table1[Date]))-1&&Table1[Week] <= i + 12 && Table1[Week] >= i ))

 

 

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

Hello @v-xicai 

 

Thank you so much for sending an alternative solution.  Although I think your Measures will work, I think @mahoneypat solution is slightly better suited for my clustered column chart.

Thanks again and kudos to you as well!

 

Kind Regards,

mahoneypat
Microsoft Employee
Microsoft Employee

Assuming you have a Date table with a WeekNumber column, you should be able to use a measure like this that should give nonblank/shown values for the last 13 weeks.

 

NewMeasure =
VAR thisweek =
    WEEKNUM ( TODAY () )
RETURN
    CALCULATE (
        [Your Measure],
        KEEPFILTERS (
            FILTER (
                ALL ( 'Date'[WeekNumber] ),
                'Date'[WeekNumber] <= thisweek
                    && 'Date'[WeekNumber] >= thisweek - 12
            )
        )
    )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





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

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hello @mahoneypat 

 

I have implemented your solution and thus far appears to be working exactly as I hoped.  Still need to do a bit more testing and validation.  But wanted to send along my thanks, appreciation and of course Kudos!

 

Best Regards,

Good Evening @mahoneypat 

 

Thanks for the reply and suggested solution.  I will give it a shot in the morning and let you know how I make out.

 

Thanks again and Best Regards,

Helpful resources

Announcements
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 Kudoed Authors