The problem is that for understandable reasons, the _time column is no longer present. Is there any way to retain the _time column while also retaining the query’s functionality? Bing Chat has failed so far in solving this problem.
another more complicated is to create 2 queries one to get the average, then other to get the “last” or “first” value and then combine the two and keep only one single point with the value of first query and time of the second query.
a third option could be to do another aggregateWindow on which every equal to the total duration in between _start _stop. that way the result will be only one data point
also for the sum() you could replace that whith cummulativesum and last:
This yields the correct result and avoids using a reduce function. There is a bit of repetitive code that I don’t know how to replace with better code; if you see any opportunities for simplification, that would be very welcome.