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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
MNH
New Member

Power BI Running Total Cumulative Value for 12mth periods

Hi, I am new to PowerBI and have been getting to grips with how DAX works.  I've hit the wall with trying to get a running total cumulative value that .  Below shows what I am trying to achieve.  I have a simple table with 2 columns - Period and Period Count.  I can build a cumulative total in DAX that increments each month and continue on for all months (Column callced Cumulative Count DAX below).  However, what I'm after is for the cumulative value in a period to be the sum of the previous 12 months.  For example, in Period = 202008 return a sum of this month plus the previous 11 months.  Then do the same for 202009 and so on.  I tried setting a start date and end date for each Period so that, for example, 202008 has start date of 1/09/2019 and end date of 31/08/2020 in order to CALULATE SUMX of counts between a date range involving start date and end date but don't get what I'm after.  I've tried using DATESINPERIOD and RELATEDTABLE in various formulas but drawn a blank.  All I get is a cumulative total for all months or the value for just the month.  Any ideas whether what I am trying to achieve is even possible?

MNH_2-1671117973643.png

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@MNH , You can try rolling 12

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

 

if need, create a date from the month year

 

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

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for taking the time to look.  I've watched the YouTube link and attempted to apply the formula to my dataset.  However, I get different results to expected.

 

This is one of the measures

Cumulative attempt 1 = CALCULATE(SUMX(RELATEDTABLE('Data'),[Count]),FILTER(('Data'),'Data'[Date]>=[Date minus Year] && 'Data'[Date] <= 'Data'[Date]))
 
This measure is from your example, which I can see working perfectly in your YouTube clip but doesn't on my dataset.  What could be going wrong?
Cumulative attempt 2 = CALCULATE(SUM('Data'[Count]),DATESINPERIOD('Data'[Date],MAX('Data'[Date]),-12,MONTH))
 

MNH_0-1671179978601.png

 

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!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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