Store previous value with Save only changed values enabled

Started by mashedpotatorocket, November 16, 2022, 12:56:42 PM

Previous topic - Next topic

mashedpotatorocket

Hello.

I'd like to share an observation on the new DCI setting Save only changed values.

Let's say we track the size of a database file, polling once a day. It is 10 GB, and it doesn't change from day to day, so only the first value is stored. The DCI timestamp is updated each day (this is important).

One month later the file size suddenly increases from 10 to 30 GB. The new DCI value is stored. Let's take a look att the historical values:

Day 1: 10 GB
Day 30: 30 GB

Now, imagine we plot a graph. It would be a straight line increasing each day, even though we know that the file size is 10 GB up until day 30. What I would like to see is the same graph we would have if we polled each day with "Save only changed values" disabled, a graph that shows that the file size was 10 GB on day 29 and 30 GB on day 30.

I suppose it could be done this way:
On day 30, when we detect that the file size is different from the previous poll, store *both* the old value (10 GB) with the last timestamp (Day 29), and the new value (30 GB) with the current timestamp (Day 30). The historic values would look like this:

Day 1: 10 GB
Day 29: 10 GB
Day 30: 30 GB

When plotting a graph, if would correctly show that the file size is constant up until day 30.

MarcusH

Sounds like chart needs an option like grafana has that is called "step before" and "step after" meaning graph has a straight line until change in value