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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.