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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
MarceloSaez
Helper I
Helper I

Running sum based on value change

Hello.

I need to calculate the running cumulative of the column "Oil", but reset the calculation every time the column "Name" changes.

Note that the column "Date" is important also because the running sum is time-correlative.

My Data:

Date Name Oil
01/01/2000 M-1 210
01/02/2000 M-1 195
01/03/2000 M-1 266
01/04/2000 M-1 223
01/05/2000 M-1 190
01/06/2000 M-1 247
01/07/2000 M-1 233
01/08/2000 M-1 219
01/03/2002 M-2 197
01/04/2002 M-2 160
01/05/2002 M-2 180
01/06/2002 M-2 160
01/07/2002 M-2 156
01/03/2002 M-3 174
01/04/2002 M-3 177
01/05/2002 M-3 180
01/06/2002 M-3 169
01/07/2002 M-3 165

 

What I want to achieve:

Date Name Oil Oil_Cum
01/01/2000 M-1 210 210
01/02/2000 M-1 195 405
01/03/2000 M-1 266 671
01/04/2000 M-1 223 894
01/05/2000 M-1 190 1084
01/06/2000 M-1 247 1332
01/07/2000 M-1 233 1564
01/08/2000 M-1 219 1783
01/03/2002 M-2 197 197
01/04/2002 M-2 160 357
01/05/2002 M-2 180 537
01/06/2002 M-2 160 697
01/07/2002 M-2 156 853
01/03/2002 M-3 174 174
01/04/2002 M-3 177 352
01/05/2002 M-3 180 531
01/06/2002 M-3 169 700
01/07/2002 M-3 165 865

 

Any help would be greatly appreciated.

Best regards,

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@MarceloSaez 

please try to create a column

Column = SUMX(FILTER('Table','Table'[Name]=EARLIER('Table'[Name])&&'Table'[Date]<=EARLIER('Table'[Date])),'Table'[Oil])

1.PNG 





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

Proud to be a Super User!




View solution in original post

amitchandak
Super User
Super User

@MarceloSaez , Try a new column like

cumm_oil = sumx(filter(Table,Table[Date] <= earlier(Table[Date]) && Table[name] =earlier(Table[name])),Table[Oil])

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@MarceloSaez , Try a new column like

cumm_oil = sumx(filter(Table,Table[Date] <= earlier(Table[Date]) && Table[name] =earlier(Table[name])),Table[Oil])

ryan_mayu
Super User
Super User

@MarceloSaez 

please try to create a column

Column = SUMX(FILTER('Table','Table'[Name]=EARLIER('Table'[Name])&&'Table'[Date]<=EARLIER('Table'[Date])),'Table'[Oil])

1.PNG 





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

Proud to be a Super User!




Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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