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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Cumulative value with conditions (or other solution)

Hello fellows! I have little experiencie with DAX. I've been trying to create an expression to solve my problem.

I have a 3 tables.

Initial Stock (not linked with DateTable, because it is a snapshot of my current stock position)

Transit (linked with DateTable)

Demand (linked as well)

Final_Stock ( Initial Stock + Transit - Demand)

rcoutin_0-1646922867056.png

 

Here is where I'm stucked, what I've been trying to accomplish.

I have the initial stock and did the measure to give me the Final Stock for this month (Initial Stock + Transit - Demand) .

However, for the calculation for the next months, the initial stock to be considered should be the final stock from previous month.

The biggest problem I'm facing: If the final stock from previous month is negative, the next month should considere 0 as the initial stock and start over the process again.

 

What I did and is not working well.

 

Cumulative Total =
      CALCULATE(Medidas[Final_Stock],
               FILTER(ALL('Date'),
               'Date'[Date] <= MAX('Date'[Date])
          )
)
 
I tried to create a conditional formula, but is not working correctly.
 
rcoutin_1-1646924086920.png

 

Any help will be appretiated!!!

Thank you all.

2 REPLIES 2
Whitewater100
Solution Sage
Solution Sage

Hi:

Something like:

 = 

Measure = IF(CLOSINGBALANCEMONTH([Final_Stock], Dates[Date]) < 0, 0, CLOSINGBALANCEMONTH([Final_stock],Dates[Date]))
Anonymous
Not applicable

no... it is repating the value across the months

 

rcoutin_0-1646925566810.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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