I honestly see the same problem as in the other topic:
You are querying an interval of 1h (range(start: -2h, stop: -1h)) and then aggregating in intervals of 1h (aggregateWindow(every: 1h, fn: last, createEmpty: false)). The aggregateWindow function will return only one record for the interval especified and therefore, the difference function will not return anything since it needs two subsequent records to compute a difference.
If you want to get the last hour, why don’t you use:
- range(start: -2h)
and then, if aggregate by every hour:
- aggregateWindow(every: 1h, fn: last, createEmpty: false)
In this way, you will get the last value of both intervals (-2h to -1h, -1h to 0h). After doing this, if you apply difference, this will compute the difference between both intervals. This difference is the energy usage for the last hour, as you requested.
Let me know if that is what you expected.