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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
vanessacalalang
Frequent Visitor

4month rolling total

Hi, Can someone helpme please? 

I need to create a matrix to show  4months total of sales per client. 

From this Sales table ( I just did mock up data in excel)

vanessacalalang_0-1662952602683.png

I need to have  matrix in power bi showing 4month rolling total like this:

i.e. Client 1 Jan value 0f 700 is a total from Jan - Apr value ( 100+200+300+100) and so on. 

vanessacalalang_1-1662952637377.png

My data set containt Clients, Date( From Jan 2022 - Dec 2023 and Value colum. 

vanessacalalang_2-1662952707948.png

I tried a lot of formulas that i can see online but nothing seemed to work. Can anyone help me, please? Thank you so much in advance. 
Cheers,
Vanessa

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI  I add an index column , then calculate it in below formular. then you can delete index column

= Table.AddColumn(#"Added Index", "Custom", each List.Sum(Table.SelectRows(#"Added Index",(a)=>a[Index]<=[Index]+3 and a[Index]>=[Index] and a[Clients]=[Clients])[Value]))

Youngli_0-1663053845725.png

 

View solution in original post

7 REPLIES 7
vanessacalalang
Frequent Visitor

Hi @Jihwan_Kim


Sorry I missed your raw data. This is exactly what I need except I need to derive the "value" from the measure that I created as there are other calculations into it. Any advise on how can I get the SUM of the "measure" so I can use your brilliant formula? Thansk! 

Cheers,
Vanessa

Anonymous
Not applicable

HI  I add an index column , then calculate it in below formular. then you can delete index column

= Table.AddColumn(#"Added Index", "Custom", each List.Sum(Table.SelectRows(#"Added Index",(a)=>a[Index]<=[Index]+3 and a[Index]>=[Index] and a[Clients]=[Clients])[Value]))

Youngli_0-1663053845725.png

 

Hi @Anonymous ,

I tried this solution and it worked. Although when I put it in matrix and used the "Custom" value that was created from this formula, the Row Subtotal is not correct. Is there a way to reflect the correct Row Subtotal? Thanks! 

Cheers,
Vanessa

Hi Youngli 

Please disregard my innocence. I got it. Thank you so much for your help. 

Cheers,
Vanessa

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below, and I hope the below can provide some ideas on how to create a solution for your dataset.

 

Jihwan_Kim_1-1662964172015.png

 

 

Jihwan_Kim_0-1662964157264.png

 

Expected measure: =
CALCULATE (
    [Value sum measure:],
    'Calendar'[Date] >= MIN ( 'Calendar'[Date] ),
    'Calendar'[Date] <= EOMONTH ( MIN ( 'Calendar'[Date] ), 3 )
)

 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi Jihwa, 


Thanks for your response but I don't think it's the right formula of what I'm looking for. Say if we use value on the table that you have there as example. I need the formula to show the rolling 4month totals like this:

vanessacalalang_0-1663027763522.png

For Jan-22 = values for (Jan+Feb+Mar+Apr). So for Client1 = 30+30+26+31 hence 117. For Feb = values for (Feb+Mar+Apr+May). So for Client1 = 30+26+31+31 hence 118. It's easy to do it in excel but I can't seem to pathom the right formula in Power BI. Appreciate your help. Thanks!

 

Cheers,
Vanessa

 

 

Hi,

Thank you for your feedback.

I am confused a little bit. I created a sample, and in my sample, Client01 has 6 on January, 9 on Feb, 5 on March, and 10 on Apr. So, 6+9+5+10 = 30

Do you mean that, for Client01, after you create 4 months rolling, and then do the calculation again for 4 months rolling? 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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