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
Anonymous
Not applicable

Cumulative Total of a Measure for last 3 months

Hi Team,

I have been working on a report where I'm trying to add a Cumulatve Total of a Measure of last 3 months to a table.  I used the below measure to arrive at cumulative score however its cumulating all the previous rows and not just last 3.

Cumulative Value=
 
var thismonthyear = SELECTEDVALUE('Date'[Month Year],0)
 
RETURN
CALCULATE(
SUMX(VALUES('Date'[Month Year]),
'Measures Table'[Measure Value]),
 
'Date'[Month Year] <= thismonthyear)

I'm looking for a way to sum only previous 3 rows in the cumulative Value

img.png

 


1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try my method.

Measure:

Cumulative 3 months = 
Var N1=SUMMARIZE(FILTER(ALL('Date'),[Month Year]<=MAX('Date'[Month Year])),[Month Year],"Sum",[Measure])
Var N2=TOPN(3,N1,[Month Year],DESC)
return
SUMX(N2,[Sum])

vzhangti_0-1653386299476.png

 

Best Regards,

Community Support Team _Charlotte

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

5 REPLIES 5
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try my method.

Measure:

Cumulative 3 months = 
Var N1=SUMMARIZE(FILTER(ALL('Date'),[Month Year]<=MAX('Date'[Month Year])),[Month Year],"Sum",[Measure])
Var N2=TOPN(3,N1,[Month Year],DESC)
return
SUMX(N2,[Sum])

vzhangti_0-1653386299476.png

 

Best Regards,

Community Support Team _Charlotte

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

Hello! I have tried your solution and it worked great! I was wondering how could this be modify to be cumulative 3 months prior to the current month, for example:

 

Current month = September

Cumulative Last 3 Months = June+July+August

 

Hope this clarifies my question. thank you in advance.

Anonymous
Not applicable

Hello @v-zhangti , I tried your solution and it worked like a charm. Thank you so much .

PC2790
Community Champion
Community Champion

Hey @Anonymous ,

 

Try:

Sales (last 3 months) =
CALCULATE (
    SUM ( Sales[Sales] ),
    DATESINPERIOD ( ‘Date'[Date], MAX ( ‘Date'[Date] ), – 3, MONTH )
)
Anonymous
Not applicable

Hi @PC2790 , Thanks for your quick input. Unfortunately field "Measure Value" is a complex measure and not a column hence I'm not able to use it in the above formula you have suggested.  Is there another way ?

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.