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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
jdwalker5
Helper II
Helper II

Rolling 4 Week Total

Hello,

 

I'm trying to get a rolling 4 week total for each row in a summarized table.  Example below with expected result.

WeekItemTotalRolling 4 Week Total
8A550
7A1070
6A1590
5A20110
4A25130
3A30105
2A3575
1A4040

 

The 'Rolling 4 Week Total' column should sum the 'Total' column of the last 4 weeks.  For example, for week 8 the rolling 4 week total is a sum of 5, 10, 15, 20.

Hope I'm explaining that well enough, but let me know if more info is needed.

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

ThxAlot_0-1712385720529.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

6 REPLIES 6
v-nuoc-msft
Community Support
Community Support

Hi @jdwalker5 

 

@amitchandak  @ThxAlot Thank you very much for your prompt reply. Here please allow me to post some of my methods.

 

For your question, here is the method I provided:

 

Here's some dummy data

 

“Table”

vnuocmsft_0-1712558887889.png

 

Create a measure.

 

 

Rolling 4 Week Total = 
    CALCULATE(
        SUM('Table'[Total]), 
        FILTER(
            ALL('Table'), 
            'Table'[Week] > MAX('Table'[Week]) - 4 
            && 
            'Table'[Week] <= MAX('Table'[Week])
        )
    )

 

 

 Here is the result.

vnuocmsft_1-1712558940413.png

Regards,

Nono Chen

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

@v-nuoc-msft ,

Thanks for the reply! I ended up bringing in a separate dataset where I used a SQL window function to get the result I needed, but this looks like it would work.  Appreciate you looking into this!

ThxAlot
Super User
Super User

ThxAlot_0-1712385720529.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Thanks @ThxAlot!  I didn't realize window functions were available in DAX, but that is really good to know.  I played around with it some, but couldn't quite get it to work.  That's probably on me for missing something in the syntax.  I ended up using a SQL window function and brought in a new dataset.  Thanks again for your reply!

amitchandak
Super User
Super User

@jdwalker5 , Prefer to have a separate table with Week on Year week depending on the data. If this year's week creates a rank column, for only week you use week in place of week rank

 

 

Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW format

 

Last 4 weeks = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-4 && 'Date'[Week Rank]<=max('Date'[Week Rank])))

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thanks @amitchandak ,  I did not have a chance to try your solution out, but it looks like it probably would have worked.  I ended up pulling in a new dataset and used a SQL window function, but I appreciate you taking the time to respond!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.