stateChangeOnly() returns only one direction

Hello,
I’m new to flux, but spend meanwhile several hours to get a simple problem solved.
I want ro measure the runtime of a heat pump.
I have nice graphs showing the power consumption.
I add a column to this table with
|> map(fn: (r) => ({
r with
_level:
if r._value > 1000.0 then “ok”
else “info”
}))

I can see the column _level having ok and info
but when I add
|> monitor.stateChangesOnly()

the returned table has only “info”. No transition to ok.
When I swap the mapping above I can change that to ok.

with monitor.stateChanges(toLevel: “ok”) I can get also the ok states,
but I would like to have both as ChangesOnly supposes to do.
Any hint?

figured it out, stateChangeOnly returns 2 tables - strange
result=_result _level=ok
result=_result _level=info

How to merge that 2 tables?
join did not work

and now the solution:

monitor.stateChangesOnly()
|>group()
|> sort(columns: [“_time”])

I wonder, if I’m the only one, following the TL;DR tutorial. Haven’t seen any group statement. Is it a bug or a feature?

:slight_smile: Somewhere in the middle. It’s a little-understood behavior of the function. It groups output data by _level (see the function source code). This functions is specifically designed for the InfluxDB monitoring middleware which expects this behavior, but IMHO, it doesn’t fit the general need of returning state changes only. There are a few issues on the Flux repo related to this: