Hi All,
I'm trying to write a column formula that will look at the difference in date between two rows and if >= than a certain value (in this case 4 days), then the column should decrement the phase value. If the date difference is <4 then it should keep the previous phase value. I've defined two local variables in the formula: phase and MinDaysbreak, which is the minimum days between phases (4). The column :"Date/Time:"n is the date column that the For() loop is iterating through.

My formula looks like the following:

And the JSL code for the formula is the following:
For( i = N Rows(), i >= 1, i--,
If( i == N Rows(),
phase,
If( Abs( Date Difference( :"Date/Time:"n[i + 1], :"Date/Time:"n, "Day" ) ) >= MinDaysbreak,
phase--,
phase
)
)
)
I'm not getting any errors for the formula, the formula is not suppressed, but the column is still empty. I still get nothing for the last row even if I remove the first else statement in the first If(), and the last entry for the column should be 9, as that's the local variable phase. I know that there are 9 phases.
I'm not sure what I'm doing wrong, but I wouldn't be surprised if it's a simple mistake that I'm overlooking.
Thanks for any help!,
DS