One option is to change the Diff column to perform the comparison
If(Dif(Num(:Pos UCN), 1) <= 5 | Abs(Dif(Num(:Pos UCN), -1)) <= 5,
1,
0
)
Or just calculate minimum difference and then perform check after
Min(Dif(Num(:Pos UCN), 1), Abs(Dif(Num(:Pos UCN), -1)))
-Jarmo