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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
KH11NDR
Helper IV
Helper IV

How do I do a running total by row in a measure, columns are months?

Hi Guys,

 

How do I do a running total by row in a measure, columns are months?

 

                 Jan      Feb      Mar

Sales       1000:  3500:      6000

 

Thanks

 

Lak

6 REPLIES 6
KH11NDR
Helper IV
Helper IV

The calculation im trying to do.

 

calc.png

So, I would still unpivot your months. What you would want to do would be to create a measure that calculates the current month. You would have another measure that calculates for the months previous and does not include the current month. Then you can just subtract them to get the number you are looking for. So, in psuedo-code it would be something like:

 

Measure Current Month = 

VAR __currentMonth = MONTH(TODAY())

RETURN SUMX(FILTER('Table',[month] = __currentMonth),[Value])

 

Measure Previous Months = 

VAR __currentMonth = MONTH(TODAY())

RETURN SUMX(FILTER('Table',[month] <> __currentMonth),[Value])

 

Measure Difference = [Measure Current Month] - [Measure Previous Months]

 

Specifics will vary but that's the general idea. With DAX, you can't think in terms of individual cells and rows, DAX is all about tables and columns.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

That didn't work 😞

 

I get figures for previous month, that are the same figures for current month and nothing at all for previous month.

Sorry, I never saw this, I'll give it a go.

Greg_Deckler
Community Champion
Community Champion

Usually you would unpivot your months and then it is trivial. Is there a reason you can't do it that way? 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

There's a further calculation i need to make, I need to, calculate all sales up to previous month and subtract the figure with the number in a above row.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.