I have the following query:
from(bucket: “testdb”)
|> range(start:2023-01-10T12:00:00.000+02:00, stop:2023-10-20T14:00:00.000+02:00)
|> filter(fn: (r) => r[“_measurement”] == “data”)
|> filter(fn: (r) => r[“tag”] == “T1” or r[“tag”] == “T2” or r[“tag”] == “T3”)
|> keep(columns: [“_time”, “_value”, “tag”])
|> pivot(rowKey: [“_time”], columnKey: [“tag”], valueColumn: “_value”)
|> map(fn: (r) => ({ _time: r._time, calc: (r.T1* r.T2) / r.T3}))
|> aggregateWindow(every: 3600s, fn: mean, column: “calc” )
|> yield()
Instrument values are written to a measurement called “data”. Each value written has a tag associated with it. I chose this schema as the amount of sensors grow above 200 which is the column limit ot a measurement.
Now, I need to do calculations on these instruments. The query is an example. The problem I’m having is if the timestamps are unequal between the different tags then lots of nulls are created and calculation results end up being mostly null if the timestamps are not exactly the same.
How can I equalize the timestamps to be the same to create a nice time, T1, T2, T3 row where I can do my calculations ? Performance is extremely important. I’ve tried interpolation with not much success. Think I applied it incorrectly.