I have a revolving counter variable that counts until 255 and then reset.
Now I need to calculate a synthetic variable with it so I have variable -shift(variable,-1) so my problem is that when variable reset that subtraction will be negative and it couldn’t be.
Any tips on how can I still make shift operation but not having that problem?
I tried with where but do not know if it will work.
The way I see it a simple
abs() function would the trick. You can wrap your expression app with the
abs()function as follows:
abs(var - shift(var, -1))
Hope this helps.
If I remember correctly, the only thing abs does is return the value in positive, right?
Imagine current value 200 and previous 190; for this case it would be x = 10.
But if we put 5 and previous 255 for example, x = 250 and this would not be the correct result.
Thanks for the help.
That’s quite right, I did not think correctly about the revolving condition. Nevertheless, now that I have, here is an expression that I’m sure works after giving a shot:
a = var b = shift(var, -1) where (a > b, a - b, abs(255 - b + a))
Thanks @dsr I forgot I could just use variables as you writed…