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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Art666
Frequent Visitor

DAX Cumulative Total incremented by this total

Hi, Has anyone a idea how to solve this situation in DAX.

In Excel it is quite easy becasue you can always refer to a specific cell.

 

I need to increment the A Value by B Value, and if A is Blank the A increment should happen by the previous result of the calculation.

 

Art666_0-1718292918553.png

 

Thank You in advance!

3 REPLIES 3
vicky_
Super User
Super User

I have my data setup like so (actually the 550 in the data isn't used at all, i just need the starting values for A and B and the number of rows to go up to... and the row and the starting values don't even need to be in the same table):

vicky__0-1718319702528.png

And then a measure:

Sum of A = 
var firstAValue = CALCULATE(MIN(Cumulative[A]), Cumulative[Row] = 0)
var firstBValue = CALCULATE(MIN(Cumulative[B]), Cumulative[Row] = 0)
var currentRow = SELECTEDVALUE(Cumulative[Row])
var result = firstAValue * IF(currentRow = 0, 1, currentRow) + (firstBValue * (IF(currentRow = 0, 1, currentRow) - 1))
RETURN result

which you can adapt to get the value for B

Art666
Frequent Visitor

Hi vicky_

Thank you for your help.

 

However it is still not working:

Art666_0-1718377327569.png

 

Art666_1-1718377363953.png

 

Any idea why this could fail?

 

PS. I made the same calculation on hard pasted data and it seems to work.

Above a have a summarisecolumn table.

 

 

vicky_
Super User
Super User

I have my data setup like so (actually the 550 in the data isn't used at all, i just need the starting values for A and B and the number of rows to go up to... and the row and the starting values don't even need to be in the same table):

vicky__0-1718319702528.png

And then a measure:

Sum of A = 
var firstAValue = CALCULATE(MIN(Cumulative[A]), Cumulative[Row] = 0)
var firstBValue = CALCULATE(MIN(Cumulative[B]), Cumulative[Row] = 0)
var currentRow = SELECTEDVALUE(Cumulative[Row])
var result = firstAValue * IF(currentRow = 0, 1, currentRow) + (firstBValue * (IF(currentRow = 0, 1, currentRow) - 1))
RETURN result

which you can adapt to get the value for B

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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