Hello everyone,
I have been looking for a while to compare data (external temperature sensor) between yesterday and today.
For example, my value array is:
Now I’m trying to superimpose yesterday’s temperature values on today’s temperature values to make the comparison, so I looked for a solution via the “experimental.alignTime” command but it doesn’t work well:
I agree with you that the experimental.alignTime function in Flux does not really work for this purpose. Having said that, this question (a day-over-day or week-over-week or year-over-year time series graph) comes up a lot and I have yet to see a definitive solution. I am going to try to work out the Flux functions needed. I am 90% sure this is possible. Just need to spend some time on it.
Thank you for your reply.
Already, I know it’s not the right solution, I’ve been looking for a while but I was afraid of doing something wrong.
For the initial request, it is certain that the comparison between data is really something that is missing.
I wonder if a solution would not be to offset the data like
But I don’t know the InfluxDB language well.
For your information, in the meantime, I found a little solution which consists of displaying two graphs, it’s not the best either:
I’m having a little trouble understanding the InfluxDB code but that’s because I’m a beginner in this language.
I was having trouble with the UTC offset and my TimeZone in UTC+2h with the line of code:
timeDifferenceDuration = duration(v: uint(v: now()) - uint(v: lastRow._time)) // UTC timestamps needs to be converted in UNIX/epoch timestamp with uint(). lastRow._time selects _time column from lastRow variable.
I tinkered with something, but it’s not the best when you change the time:
time1 = uint(v: date.add(d: 2h, to: now()))
//time1 = uint(v: system.time())
time2 = uint(v: lastRow._time)
timeDifferenceDuration = duration(v: time1 - time2) // UTC timestamps needs to be converted in UNIX/epoch timestamp with uint(). lastRow._time selects _time column from lastRow variable.
Now, I need to understand better how influxDB2 works, particularly so as not to fixe the dates like this:
|> range(start: 2023-10-17T21:57:00Z, stop: 2023-10-18T21:57:00Z) // Here use time range in which you find your original (imported) data
In any case, thank you to both of you and then to the Grafana team.
I discovered the tool and I must admit that it is rather well designed and powerful.