Integral Function not returning expected

I have a flux query that gets the integral of some data and I noticed an inconsistency with the function that I would like explained if at all possible. For example, lets say I want to get the integral over a 15 min interval:

    _value	            _start                      _stop                        _time
23706.40067    	2022-03-08T19:15:00.000Z	2022-03-08T19:30:00.000Z	2022-03-08T19:15:00.000Z
23706.26172	    2022-03-08T19:15:00.000Z	2022-03-08T19:30:00.000Z	2022-03-08T19:15:56.614Z
23707.85742	    2022-03-08T19:15:00.000Z	2022-03-08T19:30:00.000Z	2022-03-08T19:27:56.617Z

Influx will return what I expect, 21,336,427,687,765,830 (when integral unit = ns). But lets say I attempt to get the integral of this data:

  _value	            _start	                     _stop	                    _time
23707.33292	    2022-03-08T21:00:00.000Z	2022-03-08T21:15:00.000Z	2022-03-08T21:00:00.000Z
23707.20898	    2022-03-08T21:00:00.000Z	2022-03-08T21:15:00.000Z	2022-03-08T21:03:59.521Z
23707.80664	    2022-03-08T21:00:00.000Z	2022-03-08T21:15:00.000Z	2022-03-08T21:08:54.723Z
0	            2022-03-08T21:00:00.000Z	2022-03-08T21:15:00.000Z	2022-03-08T21:08:55.683Z
0	            2022-03-08T21:00:00.000Z	2022-03-08T21:15:00.000Z	2022-03-08T21:09:04.323Z
23707.80664	    2022-03-08T21:00:00.000Z	2022-03-08T21:15:00.000Z	2022-03-08T21:09:05.283Z
23707.47379	    2022-03-08T21:15:00.000Z	2022-03-08T21:30:00.000Z	2022-03-08T21:15:00.000Z

This interval will return the value 1,574,762,662,963,110,700 which is a bigger number than I was expecting… I was expecting a number similar to the data set above. It seems as if the 0’s are causing this. When I increase those 0’s, I begin to see the number I would like to achieve. Why does Influx do this and is there anyway to prevent this from happening? What is going on in the integral function???

I would like to emphasize what’s going on here by sharing a little bit more about the issue I am experiencing regarding Influx’s built in Integral function. In the picture attached, I have quite a bit going on. I am trying to compare how another historian is doing their integrals vs how Influx is doing it. While I’m not expecting Influx to work exactly the same, the differences in my opinion are quite shocking.

In the attached image, I pulled raw data down from historian number 1 (the historian I am using to compare to Influx) and I also pulled raw data down from Influx. I chose a 15 min interval and the data is relatively the same between historians (the data I have in Influx is slightly compressed). I then manually calculated the integral in both days and nanoseconds. As shown in Step 5, the results are just about the same, only a 0.00033% difference was shown between the two manual calculations.

I then preformed a server side integral on both data historians. The first historian, returned a value similar to both manually calculated integrals whereas influx returns a value that is not even close… The value Influx returns has a percent difference of 194.71% when compared with the manual calculations.

Here is the flux I am using to return the Integral in nanoseconds:

offset=duration(v: string(v: uint(v: 2022-03-08T20:00:00.0000000Z)-uint(v:date.truncate(t: 2022-03-08T20:00:00.0000000Z, unit: 900s))) + "ns")

from(bucket: "MyBucket")
    |> range(start: 2022-03-08T20:00:00.0000000Z, stop: 2022-03-08T22:00:00.0000000Z)
    |> filter(fn: (r) => r._measurement == "Air_Temp" and r._field == "Value")
    |> window(every: 15m, offset: offset, createEmpty: true)
    |> integral(interpolate: "linear", unit: 1ns, timeColumn: "_time")

What is going on here and why is there such a vast difference between my manual calculation and what Influx is doing to calculate these values? Is there a way to stay consistent with my manual calculations while still using the server side integral flux function?

Hello @ticchioned,
Thanks for sharing the detailed explanation.
I don’t know why this behavior is happening.
I created this issue:

1 Like