Continuous integration in an archive or how to do a sawtooth diagram


A few days ago, a colleague came to me and asked for advice. “I need to sum, more precisely I need to integrate the energy consumption but in a way that at the beginning of every work shift, the number will be zeroed. So, the diagram would be resembling teeth of a saw – it will rise, and rise, and then on the edge of the work shift, it will be zero again. Could this be done in an elegant way – preferably right in the archive without needing to calculate somewhere in the ESL script?”

This is a companion discussion topic for the original entry at