# Valuewhen statement n=0

ValueWhen(EXPRESSION, ARRAY, n = 1)

I understand that n=1 is the most recent occurrence and negative numbers are future occurrences.

What does it mean when n=0 ? I get vastly different results between n=1 and n=0 but am trying to understand further.

Values smaller than 1 look for expression being true in the "future". So then it is looking ahead in the array contrary to looking backwards.
But that is pretty much mentioned in documention already.

AFL Function Reference - VALUEWHEN
Returns the value of the ARRAY when the EXPRESSION was true on the n -th most recent occurrence.
Note: this function allows also 0 and negative values for n - this enables referencing future

BTW, answering questions and writing code takes time. It would be appreciated to give some feedback instead of just going from one topic to next topic. No response/zero feedback here, for example. Thank you!

5 Likes

Thank you fxshrat for the help, it is much appreciated!!!

1 Like

You're welcome!

Here is an Excel table to explain difference between `n = 0` and `n = 1`.
Rows 4 and 5 are arrays returning result of ValueWhen but each one with different n-value (3rd function argument). So as you can see row 4 looks backward while row 5 is looking forward in the array returning array element of row 3 when row 2 is TRUE. 3 Likes

Thanks for Detailed Explanation