Calculate mean of values across multiple tables?

Say that I perform a query like this:
from(bucket: "MyBucket")

  |> range(start: -1d, stop: 1d)

  |> filter(fn: (r) => r["_measurement"] == "AvgData")

  |> filter(fn: (r) => r["_field"] == "Mean Information")

Which results in a number of tables, of which could be any number, with any name, and data that looks like this:

What I want to do is to construct a query such that I can, for every _value in each of the tables that has the same timestamp, average them and display the result. That is, there would be a single table of timestamps with a corresponding value that was a mean of the row in each Table that has that same timestamp.

Is it possible to create a query to do this?

1 Like

I found a way to do this, using this form:

My query is in this form:
from(bucket: "MyBucket")
|> range(start: -1d, stop: 1d)
|> filter(fn: (r) => r["_measurement"] == "AvgData")
|> filter(fn: (r) => r["_field"] == "Mean Information")
|> group(columns: ["_time", "_field"], mode:"by")
|> mean()
|> map(fn: (r) => ({
time: r._time,
MeanAggregate: r._value
}))

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.