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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Users online (25)