timeWeightedAvg() function
The timeWeightedAvg()
function outputs the time-weighted average of non-null records
in a table as a float.
Time is weighted using the linearly interpolated integral of values in the table.
timeWeightedAvg()
is an aggregate function.
Output data type: Float
timeWeightedAvg(unit: 1m)
Parameters
unit
(Required) Time duration used when computing the time-weighted average.
tables
Input data.
Default is piped-forward data (<-
).
Examples
The following example uses data provided by the sampledata
package
to show how timeWeightedAvg()
transforms data.
import "sampledata"
data = sampledata.int(includeNull: true)
|> range(start: sampledata.start, stop: sampledata.stop)
|> fill(usePrevious: true)
|> unique()
data
|> timeWeightedAvg(unit: 1s)
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, the following resources are available:
InfluxDB Cloud customers can contact InfluxData Support.