-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect results with difference() because it doesn't initialize with the last value before query time range #5174
Comments
This issue has had no recent activity and will be closed soon. |
I think it's worth to keep this open, because the issue still exists. |
This issue has had no recent activity and will be closed soon. |
I think it's worth to keep this open, because the issue still exists. |
This issue has had no recent activity and will be closed soon. |
I think it's worth to keep this open, because the issue still exists. |
This issue has had no recent activity and will be closed soon. |
Issue still exists, but I cannot reopen it. |
Currently
difference
(and most likely alsoderivative
) return incorrect results since they don't initialize the first value with the previous value before the query time range. They only allow to completely drop the first value (keepFirst
) or assume a first value of 0 (initialZero
). This doesn't work well with e.g. counters.Example:
I have a bucket with counters for water & gas consumption and want to calculate the daily consumption:
The counter increases by 1 every time a certain amount has been consumed (e.g. 1 liter for water).
I'm using this query:
If I select a single day only, I get an incorrect value for this day:
If I select also the previous day, I get the correct value, but again an incorrect value for the previous day:
In this case
initialZero
doesn't help, because in the example the first entry would have to be initialized with 1.It would be really nice if
difference
/derivative
could be fixed to initialize properly.A possible workaround would be to get #702 implemented. I assume
range(start: v.timeRangeStart, stop: v.timeRangeStop, previousN=1)
together withdifference(keepFirst: false)
would solve the problem.Note that this has been requested already some time ago for InfluxQL in influxdata/influxdb#5943.
The text was updated successfully, but these errors were encountered: