Hello,
I hope it’s a simple question for you guys.
I want to get the first entry of the current year, how do I do it?
from(bucket:"VH_Messwerte")
|> range(start: FIRST_ENTRY_OF_YEAR, stop: now())
Thanks
Hello,
I hope it’s a simple question for you guys.
I want to get the first entry of the current year, how do I do it?
from(bucket:"VH_Messwerte")
|> range(start: FIRST_ENTRY_OF_YEAR, stop: now())
Thanks
@Anaisdg do you have a solution?
Thank you very mutch.
Hello @matze1708,
Try something like:
r = from(bucket: "my-bucket")
// -2y or long enough to capture the first point written.
|> range(start: -1y)
|> first()
|> findRecord(fn: (key) => key.mytag == "t0", idx: 0)
timestamp = r._time
from(bucket: "my-bucket")
|> range(start: timestamp)
Hello,
Thank you very much.
Is here the first entry of a year taken so 365 days or the first day in the current year.
Ex: 2021-01-01T00:00:00Z?
@Anaisdg
when i put all together
r = from(bucket: "VH_Messwerte")
// -2y or long enough to capture the first point written.
|> range(start: -1y)
|> first()
//|> findRecord(fn: (key) => key.mytag == "t0", idx: 0)
|> findRecord(fn: (key) => true, idx: 0)
timestamp = r._time
expression = from(bucket: "VH_Messwerte")
|> range(start: timestamp)
|> filter(fn: (r) =>
r["topic"] == "Energie/VH/Zaehlerstand/aktuell"
)
|> count()
//|> keep(columns: ["_value"])
Gesamt = expression
|> map(fn: (r) => ({r with _value: (float(v: r._value) / 10.0 )} ))
|> yield()
I get an record from
2020-12-15T13:22:48.350916398Z
Hello @matze1708 ,
So all good?
Unfortunately not.
I would like to have the first day of the year, so 01.01.2021 or 2020-01-01
Hello @matze1708,
If you want to start your query from the first day of the year, just use that date as your start in the range function. The Flux I gave you was to return the timestamp of the first point written within a specified range.
Hi,
@Anaisdg
my solution is this:
expression=
from(bucket:"VH_Messwerte")
|> range(start: 2021-01-01T00:00:00Z)
|> filter(fn: (r) =>
r["topic"] == "Energie/WP/Zaehlerstand/aktuell"
)
|> count()
|> keep(columns: ["_value"])
Gesamt = expression
|> map(fn: (r) => ({r with _value: (float(v: r._value) / 10.0 )} ))
|> yield()
is it also possible, to group the results by day or by month?
Thank you
I have played around a little bit.
Is this a solution?
from(bucket:"VH_Messwerte")
|> range(start: 2021-01-01T00:00:00Z)
|> filter(fn: (r) =>
r["topic"] == "Energie/WP/Zaehlerstand/aktuell"
)
|> window(every: 1mo, period: 1mo)
|> spread()
|> map(fn: (r) => ({r with _value: (float(v: r._value) / 10.0 )} ))