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
Hinnantj
Frequent Visitor

Running Balance - Set to Zero if Negative, then Restart Running Balance

Hello - I have the following measures and cannot seem to resolve. Specifically, once the running balance is less than zero, I want to display zero. However, once it is back above zero, I want to restart the running balance using the increase quantity. 

 

Expected formula should calculate as follows for each day and item:

[RemainingBalance_Depot] = {Previous Day [RemainingBalance_Dept]} + {Current Day [Start_Total_Depot] + [Prod_Planned] + [Prod_Unplan] - [Monthly_Training]}

 

If [RemainingBalance_Depot] <0  then 0 else {Current Day [Start_Total_Depot] + [Prod_Planned] + [Prod_Unplan] - [Monthly_Training]}

 

Sample data with Expected Outcome is located here:

Sample Data - Expected Outcome

 

I have the following two measures, with Measure_Depot as a helper Measure. But, the RemainingBalance_Depot Measure does not IGNORE the Previous RemaingBalane_Depot if it is less than 0.

 

Hinnantj_0-1707148062691.pngHinnantj_1-1707148137325.png

If there are other measures that would get the expected outcome, then great...I am not tied to the measure above. As I am very new to DAX, I am very flexible for learning.

1 REPLY 1
lbendlin
Super User
Super User

This is impossible in DAX as Power BI has no memory.  The only way to do this is in Power Query with List.Accumulate.

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.