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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
lonerwalker
Frequent Visitor

Sum row by row in a new column

Hello everyone,

 

I need help with this, I need to create a new column that sums row by row historically from a specific column i.e,

 

A   /   B

1   /   1

2   /   3

-1 /   2

-3 /  -1

6  /  5

...

 

How can I get the column B from column A? 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @lonerwalker 

You need to add a date column or index column to compare.

If you want compare by a index column, try this,

v-xiaotang_0-1622194015187.png

Then, use the measure to calculate the total

total =
   var _ind=SELECTEDVALUE('Table'[Index])
return
   CALCULATE(SUM('Table'[value]),FILTER(ALL('Table'),'Table'[Index]<=_ind))

Result:

v-xiaotang_1-1622194015188.png

OR

If you want compare by a Date column, try this,

total =
   var _ind=SELECTEDVALUE('Table'[date])
return
   CALCULATE(SUM('Table'[value]),FILTER(ALL('Table'),'Table'[date]<=_ind))

Result:

v-xiaotang_2-1622194015189.png

 

Best Regards,

Community Support Team _ Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @lonerwalker 

You need to add a date column or index column to compare.

If you want compare by a index column, try this,

v-xiaotang_0-1622194015187.png

Then, use the measure to calculate the total

total =
   var _ind=SELECTEDVALUE('Table'[Index])
return
   CALCULATE(SUM('Table'[value]),FILTER(ALL('Table'),'Table'[Index]<=_ind))

Result:

v-xiaotang_1-1622194015188.png

OR

If you want compare by a Date column, try this,

total =
   var _ind=SELECTEDVALUE('Table'[date])
return
   CALCULATE(SUM('Table'[value]),FILTER(ALL('Table'),'Table'[date]<=_ind))

Result:

v-xiaotang_2-1622194015189.png

 

Best Regards,

Community Support Team _ Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Nishantjain
Continued Contributor
Continued Contributor

@lonerwalker when you say historically, I am assuming there a date column in your data that you can be used to identify which transaction came first. In that case you can use @Greg_Deckler  suggestion but replace the index column with your date column 

Greg_Deckler
Community Champion
Community Champion

@lonerwalker Well, you would want to add an Index column and then you could do something like the following:

B = SUMX(FILTER('Table',[Index] < EARLIER('Table'[Index])),[A])


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...

@Greg_Deckler I tried your formula but return this, the column is called "Columna", "Fecha de entrega" is a date column and "evolucion de stock" is the column used to SUMX. Also, I Filter by product in "producto terminado" for see the data. 

 

 

Captura de pantalla 2021-05-26 130644.jpg

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.