I am trying to create a history on the change of value difference rolled up in 1 hour periods for kBTU's per Hour. I am sampling a totalized value once a minute that always increases, and need to show the change up or down in BTU's per hour over the course of the day. I am using the following meta script to try to achieve this:
return p143.past(HOUR, 1).delta;
I've removed the "Updates Context" from the script context, and set the Update Event to "Start of Hour".
It seems to calculate ok, however, I am getting a negative historical value at the 1:00AM timestamp. I believe this is because I reset my totalized source script context value (p143) every day at midnight to zero, and the calculation goes negative.
How do I prevent a negative value? I am using this data in a chart, Thanks for the help.