@dewi-ny-je This is what the aggregateWindow() function is designed for:
The following example will give you your average power usage per hour over the last 30days. Just replace your-bucket-name, your-measurement-name, and your-field-name with the appropriate values to match your schema.
Since google pointed me here…
This post: Average per hour - #14 by MarioG shows how to do this.
One thing i would change is to use integral instead of mean in the aggregate window