I’m trying to figure out how to set a query to display a kWh usage over a period of time or the time period set. I have a cumulative Wh graph using this query but would like a single number of usage over that period. Basically the finish cumulative minus the start cumulative.
Also possible to use a Grafana transformation. There are many to choose from, incl. the difference between the first and last values. The “range” also might work.
First off thank you for all the replies, I’m really new Flux queries and cheated when I discovered with my example Influxdb’s ‘Script editor’ copied into Grafana.
I couldn’t get @grant2 first example to work, generated error ‘not found: failed to initialize execute state: could not find bucket “FirstBucket”’ which I change to my bucket confusing I called it buckett had the error not found: failed to initialize execute state: could not find bucket “Buckett”.
However, I did get Transform to work ! Is there anyone way of showing yesterday and the day before etc in a fixed stat box?
UPDATE
I got @grant2 example to work - case sensitive but came up with 0 as it looks like it taking one from the other at the same time period. I’m not sure about Firstbucket and Lastbuckett where those would come from.
I only tried @grant2 examples and looked at the docs but didn’t know how to implement your spread link. It took me a few days even to get Node-red to send data to Influxdb and I’ve been confused with the ‘Random walk’ data that appears in Grafana thinking it was my data
I misunderstood entirely, I assumed a cli query rather than the gui. The result of the query below gives in Influxdb ‘No Results’ as it’s taking the same value from each other hence the ‘No Results’