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.

View discussion in a popup

Replying to:
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.

 

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.