Totalized Sum of a point

I'm looking to get the totalized sum of data points. I currently have 10 modbus points that I totalize in the controller at 1 minute, 1 hour and 24 hours. Then they reset themselves based on their runtimes. So I would like to use a Meta Data point for each that would display the total of the sum of each for as long as mango has be trending them for, or at least a year. Like an odometer reading of each of the data points.

Hi Jason,
A couple of questions,
 Is there totalizing logic built into the PLC? Some of them are performing an actual integration. If there is, it's probably most accurate to use its result, if it's not, it may be easiest to use the point itself and do it all in Mango.
 Do the totalizing registers you have only get read when they're at their total value, or do they get totalled and read together, and you're interested in making Mango total when the PLCs register goes from 12345 kWh > 0 kWh (as an example).
Regardless, the logic will be something like.... (my is the variable name default for the meta point itself)
if(my.value === undefined) return 0; return my.value + point.value;
An approximation for a first integral looks like....
if(my.value == undefined) return 0; var lastValueTime = point.lastValue(1); return my.value + lastValueTime.value * (point.time  lastValueTime.time)/1000 //Integrating in seconds

I had tried using this "return Input_1.previous(DAY).sum;" from some examples to others in the forums and realized it gets the sum of the day. How would I rewrite this to get sum for more then just the day?. I just want to use the analytics that mango has on each point to get the value from.

The syntax for the history function is two arguments, PeriodType and Periods. So, point.past(DAY, 10).sum would be a 10 day sum. The problem with doing some query like this (especially if some logic were hacked in to always query to the same start time) is that it will require a lot of data reading as the data set gets bigger. Perhaps that's acceptable if you're only running it on a cron once per day, but you'll still want to do my.value + point.past(DAY).sum such that you don't have to query "point"s entire history.

Also, if I'm misunderstanding and you're reading the totalized register, you can probably do something like...
return my.value + totalizer.past(DAY).maximumValue;
and execute it on a cron. If you know that it will have its maximum value at one time or another, you could schedule the cron around then and lower the time period from DAY to whenever will capture that maximumValue.

so far this is working "return Input_1.past(MONTH,12).sum;" I run this every minute to give the client the running total in realtime. But based on your statement of using to much HP in mango to calculate this when the statistic get larger, will this be too much for a mangoES to do for 10 to 20 points?

That would depend on the density of the data queried. I'm guessing with a point like "One Minute Total" you have data for every minute, so you're asking Mango to calculate statistics over 60*24*365 = 525600 point values every minute. It's not efficient, by any stretch of the word. Whether or not the ES can handle it will depend on other load factors as well, but summing all the data every minute is not the solution I would use.

Thanks Phil,
I will be doing the totalization within the controller as your correct in stating the accuracy will be better and the load on the mangoES will stay normal.
Thanks