Maybe we can use is the fact that the solution, if the row order is reversed, is self populated in JMP?
![event reversed.png event reversed.png](https://community.jmp.com/t5/image/serverpage/image-id/35991iD2492C320390E2C4/image-size/large?v=v2&px=999)
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?