Ubidots Community

[SOLVED] How to get differential value from one variable using synthetic expression

Hi everyone,
I’m recently using ubidots as an application server for my project. i’m transmitting my data (increasing data) in one variable. In that, i need to get differential value (i.e current value - old value).

For this what kind of synthetic expression may i use?

Eg : my data = 120 …150 , 180
I need to subtract the latest one by past data (180 - 150) to get my value as 30.

Can anyone help me out with this issue?

Thanks in advance!

Hi there, the expression below should do the trick:

previous_val = shift({{var}}, -1)
actual_val = {{var}}
actual_val - previous_val

For more information, please reference our help center.

All the best