Filter / windows based on query

Hello,

I want to get a chart with the machine state. So far no problem. But the chart should include if the machine was online or offline. So my goal is to combine the 2 values. In the picture both values are shown.
In the end I want to window the machine state based on the machine connection status. So I get the machine state when the machine is online and get a disconnected state as soon as the machine is offline.
The goal should be one chart (one line) with the machine state when the machine is online and a disconnected state if the machine is disconnected:
Other way to describe this: I try to mask the Machine State data with the machine connection status.

example:
| Disconnected | OFF | ON | ERROR | ON | OFF | Disconnected |

Until now I found no way to achieve this.
I tried to map over the machine connection status but I can’t return a whole table in the map return statement…
In some way I should be able to query/ window the state data based on the connection status.

Does someone have an idea?

@bdi If you are using Grafana, would you settle for two “stacked” graphs, like this?

In my example above, I have two flux queries (one for connection and one for state). Both return boolean values.