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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Iamnvt
Continued Contributor
Continued Contributor

Running total without date,rank

hi,

 

How can I write a measure to get the running total for this below case? I know how to write for a calculated column, just wondering how it will be with a measure.

 

Thanks

 

Column1Column3ExpectedResult
A22
A35
A16
B33
B47
B512
B618
1 ACCEPTED SOLUTION

Hi @Iamnvt

 

Here you go.

 

RunningTotal Measure = CALCULATE(
SUM( MovingSum[Column2]),
FILTER(  ALL(MovingSum) ,
SUMX( FILTER( MovingSum, EARLIER( MovingSum[Column1] ) = MovingSum[Column1] && EARLIER(MovingSum[Index]) <= MovingSum[Index] ), MovingSum[Column2] )
)
)

 

This assumes you have created an index column using query editor.

 

If this works for you please accept this as a solution and also give KUDOS.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

5 REPLIES 5
Melvlee
Helper I
Helper I

Hi there,

 

Have you tried the quick measures feature?

Please refer to Quick Measures

 

Regards

Hi @Iamnvt,

 

The quickmeasure as suggested @Melvlee will not work because it will reset at every row of Column1.

 

The method suggested by @Ashish_Mathur will compute but will fail in display.  The rows will not be displayed in the same order as original data table.

 

If you want the values to be displayed in the same order as your input data you will have to bring in the index column defined in the excel work sheet by @Ashish_Mathur and sort in the table display by index column.

 

If this works for you please accept @Ashish_Mathur suggestion as a solution and do give KUDOS to me as well.

 

Cheers

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
Iamnvt
Continued Contributor
Continued Contributor

hey, I want to write a MEASURE (Calculated field), not a Calculated column.

is there any solution for that?

Hi @Iamnvt

 

Here you go.

 

RunningTotal Measure = CALCULATE(
SUM( MovingSum[Column2]),
FILTER(  ALL(MovingSum) ,
SUMX( FILTER( MovingSum, EARLIER( MovingSum[Column1] ) = MovingSum[Column1] && EARLIER(MovingSum[Index]) <= MovingSum[Index] ), MovingSum[Column2] )
)
)

 

This assumes you have created an index column using query editor.

 

If this works for you please accept this as a solution and also give KUDOS.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
Ashish_Mathur
Super User
Super User

Hi,

 

I am assuming that you want to ccreate a calculated column formula.  If that be the case, you may refer to my solution here.  Go the Data Model to see the result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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