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
bsas
Post Patron
Post Patron

Calculate cumulative amount for last 4 quarters in selected quarter

Hello Community!

Having difficulties with calculation of amount in a quarter which is cumulative total for last 4 quarters. E.G. q4 2022 should show q1-q4 2022 sum,q3 2022 should show q4 2021 - q3 2022 and so on. What I've manged to do - create measure which actually calculates needed amount but it is "too dummy" and I need better solution.

 

<>___Last4QtrTotal = 
CALCULATE( [amount], DATEADD(Period[Date],-3,QUARTER)) + 
CALCULATE( [amount], DATEADD(Period[Date],-2,QUARTER)) + 
CALCULATE( [amount], DATEADD(Period[Date],-1,QUARTER)) + 
[amount]​

 

 

 

Sample of data and needed output below:

yearquarteramounttotal for last 4 qtr
2020q15050
2020q260110
2020q370180
2020q480260
2021q190300
2021q2100340
2021q3110380
2021q4120420
2022q1130460
2022q2140500
2022q3150540
2022q4160580
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@bsas , You can try a measure like

 

Rolling 4= CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-4,QUARTER))

 

Rolling Months Formula: https://youtu.be/GS5O4G81fww

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@bsas , You can try a measure like

 

Rolling 4= CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-4,QUARTER))

 

Rolling Months Formula: https://youtu.be/GS5O4G81fww

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 for idea, changed it a little bit and it worked!

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.