Ubidots Community

All Time Summation of Variables


I have been searching around and have found a few examples of this being used for slightly different cases but nothing exactly like it. Forgive me if this is a simple solution that I am just missing…

But we want to simply add each incoming value for the same variable on top of the previous total. So if I feed the machine 5 lbs the first time and then feed it 7 lbs, I want a total of 12 to be displayed, and so on…Thus creating a widget called “total pounds digested” or similar.


Hi @psalibe,

You can achieve this cumulative summation using synthetic variables, specifically with the cumsum(x) function, which “Calculates the cumulative sum of the variable x”.
This how it look from the editor:

Makes sense?


Hello there,
I hope all is fine.Actually,my problem is also same to add all the values of a variable but,as i give zero value the sum variable must reset to zero and then ,start adding further values leaving all previous values.
Good day.

This is actually my requirement :slight_smile:

Hello @psalibe

I was going through old posts and came across this one. There is one way you can achieve what you want and that is by using two synthetic variables as follows:




fill_missing(cumsum(RAW) - AUX)

The AUX variable makes an accumulated every time the value of the RAW variable is zero, and the CUMULATIVE variable makes a subtraction between the cumsum(RAW) (that is always accumulating) and the AUX variable, to deliver the accumulated since the last time the value of the raw variable was zero. Makes sense?.

Below, you’ll find the logic of this solution.

I hope it works for you!

Have a good day,