@hans-gustav Do you have an existing Flux query or are you working from scratch? If working from scratch, what is the schema of your data? What fields and tags do you have?
I definitely need the table. I also need the scale to increase and decrease per day. This is then the difference between the first and last value. I have already developed something here.
But now the scale can also be in maintenance mode and these values ​​should not be taken into account. The information regarding maintenance is in status.
Maintenance begins at status 1. Status 2 means maintenance continues and status 3 means maintenance completed. Only the difference between values ​​0 to 0, 1 to 0 and 0 to 3 should be taken into account. In this case:
(25.2 - 25) + (25.3 - 25.2) + (27.5 - 27) = 0.8
Unfortunately I have no idea how to do this and it would be great if you could help me too.
I have another idea about status. Status 1 and 3 are omitted and are 0. Status 2 remains and indicates measurement during maintenance. This would allow you to simply take all records with status 0.
First of all, sorry for the late response and thank you very much. I try to explain what I would like.
The scale sends the absolute weight and the status of the scale at regular intervals. The statuses are normal and maintenance.
If the status is 0 then we are in normal. At 1 in maintenance. Attached an example. Red is maintenance.
Now I want the difference of every connected measurement with status 0. As soon as a status 0 measurement is interrupted by status 1, then this should be ignored. The differences should be added up. It may happen that there are several maintenance services per day.
I can retrieve the data in the influxdb as follows.
Ah, ok. I understand the use case now. The challenge is conditionally applying an aggregate operation. My initial thought is to just filter out all the rows where status is 1 and then use difference() to show the difference between subsequent rows. The problem with this approach is that you’d end up getting the difference between the last row of a status 0 “cycle” and the first row of the next status 0 cycle.
With the current functionality available in Flux, I can’t really think of a way to this. There is a proposed feature called scan() that would make this type of operation trivial. Here’s a link to the GitHub issue: EPIC: scan function · Issue #4671 · influxdata/flux · GitHub
I have a new idea. I manipulate the data with a script before writing it to the database. This means that each data record receives the current daily difference. This means I only have to display the last difference value of the day. Always the green ones here
It’s hard to pinpoint exactly what’s going on here, but I suspect it has something to do with timezone. The spreadsheet software you’re taking screenshots of (I’m guessing) is showing timestamps in your local timezone. All timestamps stored in InfluxDB are UTC. All the window boundaries defined by Flux, but default, use UTC.
What timezone are you in? Try adding your local timezone’s hour offset as an offset on aggregateWindow():