title: Convert excel formula to DAX / M
body: <p>I am trying to work out if this is possible or not in DAX or M.</p>
  <p>Basically I want to replicate this:</p>
  <p>=IF(T9&gt;0,T9-1,$Q$6)</p>
  <p>Which is the formula in T10.  So it is counting down by one if the value above it is not 0, otherwise put in a value and start counting down again.</p>
  <p>Here is some data and expected outcome:</p>
  <p><a href="https://i.stack.imgur.com/G8Aqt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G8Aqt.png" alt="enter image description here" /></a></p>
  <p>When the stock on hand drops below 5000 it triggers the lead time count down to start.  When that hits 0, it adds stock to the SOH balance, 4000 in this case.  Since the stock is below its reorder point, it puts starts the countdown again.</p>