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
RNair
Helper I
Helper I

Running Total grouped on a measure

@MFelix  and others,

 

I have attached a pbix file at the onedrive location Below.

https://1drv.ms/u/s!Aqc2e7y3QZN5mFH_F1YA9aJ7q1le?e=J2Y78g

 

RNair_0-1604378727951.png

The 1st 4 columns are raw data. SeriesID is a measure. Now I want to create a running total on Value but grouped by SeriesId.

So the result will look like this.

RNair_1-1604379071137.png

I am needing to create last column as a measure.


regards,

Ramesan



1 ACCEPTED SOLUTION

Hi @RNair ,

 

Glad you were abble to get it. Just for context what is happening is that when you use variable in a calculation that value stays fixed in this case when you make the calculation and you are picking up the SeriesID what in fact you are doing is sayin to keep the number fixed. The calculation first picksup SeriesID and then compares that "fixed value" with the one on the SeriesID that is calculated on row context.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@RNair , Try a formula like

Cumm Value = CALCULATE(SUM(Table[Value]),filter(allselected(Table),Table[date] <=max(Table[Date]) && Table[SeriesId] =max(Table[SeriesId]) ))

@amitchandak ,

Amit, Thanks for this. The problem is that SeriesId is a measure so will not be accepted as an argument for the MAX function.

Regards,

 

Ramesan 

@RNair , share the formula of SeriesId 

@amitchandak 

From Qty column you calculate a running total called QtyAft. Sometimes the QtyAft becomes zero.  

QtyAft = CALCULATE(sum(Sheet1[Qty]), FILTER(ALLSELECTED(Sheet1), Sheet1[Date]<= MAX(Sheet1[Date])))

Initially SeriesID is 1. Whenever the QtyAft reaches 0, Series ID changes for the next transaction.

 

So SeriesID is

 

SeriesID =

VAR ListOfZeros = FILTER(ALLSELECTED(Sheet1), [QtyAft] = 0 && Sheet1[Date] <= MAX(Sheet1[Date]))
Return
IF([QtyAft]= 0, CountRows(ListOfZeros), CountRows(ListOfZeros) +1 )
 
 
 
 
Screenshot 2020-11-03 154523.png

 Regards,

 

Ramesan


 
 
 
 
 
 
 
 

 



@amitchandak , @MFelix  and others,

 

I was able to create the output I needed by using a variable.

 

Output required received as follows.

 

Screenshot 2020-11-03 191239.png

 The measure **bleep** Value by Series was defined as follows.


**bleep** Value By Series =
VAR Series = [SeriesID]
Return
CALCULATE(SUM(Sheet1[Value]), FILTER(ALLSELECTED(Sheet1), Sheet1[Date] <= MAX(Sheet1[Date]) && [SeriesID] = Series))


Thank you for all the support. Feedback received in the forum has helped me to get to the solution.

Regards,

 

Ramesan

 

 

Hi @RNair ,

 

Glad you were abble to get it. Just for context what is happening is that when you use variable in a calculation that value stays fixed in this case when you make the calculation and you are picking up the SeriesID what in fact you are doing is sayin to keep the number fixed. The calculation first picksup SeriesID and then compares that "fixed value" with the one on the SeriesID that is calculated on row context.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.