I have several meters which log data upon change in value, and as such, they do not receive data with the exact same timestamp.

I now wish to generate a chart displaying the maximum combined value of several meters over time, and have decided to go with 15 minute durations. In addition to adding the values, I might need to subtract a deduct meter or multiple a given meter by a scaling constant, but this shouldn’t be any different.

https://docs.influxdata.com/influxdb/v1.5/troubleshooting/frequently-asked-questions/#how-do-i-perform-mathematical-operations-within-a-function gives the following example.

`SELECT MEAN("difference") FROM (SELECT "dogs" - "cat" AS "difference" FROM "pet_daycare")`

So, I try the following:

`SELECT max(allmeters) FROM (SELECT 0.4*meter1 + meter2 - 0.2*meter3 AS allmeters FROM meters WHERE time >= '2018-04-28' AND time <= '2018-05-02') GROUP BY TIME(900s) fill(previous)`

The problem, however, is more often than not, I do not have data for the three meters at a given timestamp, and thus have no data.

I suppose one solution would be to include a `GROUP BY`

with a smaller (but big enough) group by time, however, this is not really accurate, probably inefficient, and seems like a kludge solution. Ideally, my subquery would use the previous value (or better yet linear between the previous and next value), but I don’t know whether this is possible.

How can this be accomplished? Thank you