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
Chrystal
Regular Visitor

How to add conditions to identify the row value in cumulative calculation DAX?

Dear Key Users,

 

How could I add addtional conditions to identify the row results in cumulative calculations

 

As in the Table below mentioned, I need to cumulative the "Qty Delta" sort by the Month level, thats give me the column "**bleep** Qty Delta" in dax,

 

But I want this dax formula to add condition is if the "**bleep** Qty Delta" is positive, then the next cumulative calculation will take this positive as 0 in the next calculation, like how this will performed in column "Correct **bleep** Delta" 

 

Chrystal_0-1730966710827.png

Thanks a lot for your help!

Chrystal

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from lbendlin.

 

Hi @Chrystal ,

 

Create a new column and try the following DAX formula:

Result = 
VAR Currentmonth='Table'[Month]
VAR CurrentQtyDelta='Table'[Qty Delta]
VAR PreviousResult=CALCULATE(SUM('Table'[Qty Delta]),FILTER('Table','Table'[Month]<Currentmonth&&'Table'[Qty Delta]<0))
RETURN
IF(CurrentQtyDelta>0,CurrentQtyDelta,PreviousResult+CurrentQtyDelta)​

 

Result:

vlinhuizhmsft_0-1731404614389.png

 

Best Regards,
Zhu

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks for the reply from lbendlin.

 

Hi @Chrystal ,

 

Create a new column and try the following DAX formula:

Result = 
VAR Currentmonth='Table'[Month]
VAR CurrentQtyDelta='Table'[Qty Delta]
VAR PreviousResult=CALCULATE(SUM('Table'[Qty Delta]),FILTER('Table','Table'[Month]<Currentmonth&&'Table'[Qty Delta]<0))
RETURN
IF(CurrentQtyDelta>0,CurrentQtyDelta,PreviousResult+CurrentQtyDelta)​

 

Result:

vlinhuizhmsft_0-1731404614389.png

 

Best Regards,
Zhu

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

lbendlin
Super User
Super User

Conditional accumulation is impossible in DAX.  The only way you can do this is in Power Query via List.Accumulate() .

Hi! thanks for your reply, I will check it out!!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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