Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

How to calculate an accumulating or running total on a point.


  • I'm guessing this must be obvious to others, but for the life of me, I cannot find a way to calculate a running total.
    I have an analog point logged once a minute, and just want to create a separate meta script point to simply add each 1 minute sampled analog value to a running total. Basically a totalizer that just accumulates.


  • Hi raylatbasix,

    I would solve that using the ago(periodType, quantity) function. ago() will return the value that existed before the time. The differences with the pointValueBefore(time) is ago returns 0 should there be no alue before it (but that won't affect this)

    The other part of the puzzle is that Meta points are always in their own contexts with the meta point's variable name (by default, "my")

    So, update event: "Start of minute" script body: return my.value + p.ago(MINUTE);


  • If you wished to accumulate all values instead of just the logged averages, you could more simply have your script body be

    return my.value + p.value;

    The update event would still be start of minute to get an instant instead of the average. Or you could do a context update accumulator, but presumably there is a reason you're only wanting to accumulate the minute average, or I am misunderstanding.


  • Hi Phil,
    Thank you, that took care of it. I had everything right, but the meta points "my" variable. I was trying to declare my own variable, and it was not working.


  • Glad to hear it!