Hello,
Thanks for the message, sorry I didn’t seem to realize I copied the wrong text from DeepL.
I want to determine the value from the first day of the year to today
So always 1.1. to today
In the database is the e.g. the value 27000 to the 1.1 on today it is 28600
These differences I would like to calculate and multiply with the costs of the energy.
I am looking for the solution to calculate my consumption based on a meter reading.
For this I would need to get the first entry in the year.
Then the most recent
These two would have to be subtracted and this result would be the current consumption in the year.
I would then multiply this with a value to display the costs.
But how do I do that?
I find this InfluxDB 2.0 totally complicated. A pure SQL would be better for me.
Hi,
I have played around a bit.
Is this what I need from the query?
From the starting point, count the value up to now and output and multiply by cost?!
Hello @matze1708,
First of all, congrats on learning so much Flux! That’s impressive. Secondly, I’m sorry for the delay. Sometimes I miss messages. Please feel free to @ me in the future.
To get the first entry in the current year as a range start you could do something like:
r = from(bucket: "my-bucket")
// -2y or long enough to capture the first point written.
|> range(start: -2y)
|> first()
|> findRecord(fn: (key) => key.mytag == "t0", idx: 0)
timestamp = r._time
from(bucket: "my-bucket")
|> range(start: timestamp)