Maybe we can use is the fact that the solution, if the row order is reversed, is self populated in JMP?
For example, this will reverse the order of the events.
Event reversed:
:Event[(N Rows() - Row()) + 1]
Now the values self-populate as the calculation works from top to bottom
n rows after the reversed event:
If( :Event inverted == 1, 0,
Lag( :n rows after inverted event, 1 ) + 1
)
Finally, we reversed that column.
:n rows after reversed event[(N Rows() - Row()) + 1]
Any ideas on how to do this in one formula which is easy to interpret?