Un-Rollover Metrics?


#1

So we just got a request to deal with rollover data. Has anyone implemented some kind of metric that gracefully deals with rollovers? For example, if I have a meter that rolls over from 10mil to 0, what is the best way to capture that rollover value and dynamically add it to the total, no matter how many times it rolls? The functionality they want is the raw data: 98, 99, 100, 1, 2 etc… to instead output: 98, 99, 100, 101, 102. And to similarly continue incrementing up the next rollover so that raw 99, 100, 1 becomes 199, 200, 201.


#2

I believe you can do it as a MetricFunctionLibrary function (perhaps with a hard-coded max value), although I am not yet sure how that interact with ExpressionEngineFunction functions as far as optimizations are concerned.


#3

@jgodbey-c3iot try using the window function, e.g.

metric_shifted = window('MAX', metric, -1, 1)
metric >= metric_shifted ? metric: metric + metric_shifted

This should do the job but is very hacky/heuristic, you may also need to watch (add another if) for missings (use available) before adding.


#5

Maybe something like this would work:
rolling('SUM',rollingDiff(sum(normalized.data.quantity)) < 0 ? sum(normalized.data.quantity) : rollingDiff(sum(normalized.data.quantity)))