Stacked Bar Charts when Timestamps are not matching


I am running Grafana v9.3.1 on Raspberry Pi 4 B. I am trying to Stack values from two Goesund EP2 Smart Sockets that run Tasmota 12.2.0 and log with in InfluxDB. The timestamps of the values are not identical because I cannot (or don’t know how to) control the time when the Sockets send the values. Hence the sockets are logging every 10s they have a gap between each other of up to 5 seconds.

I thought I could just use the stacking option and Grafana would automatically group the values but I always get a zero value stacked to the actual value and never the 2 actual values together.

I also tried summing the values with Transform and a binary operation but that was also unsuccessful because I did not get a new Alias.

I think I am not seeing something fairly obvious. I don’t know and can’t find if there is an option in Grafana that stacks all values in the range of 10 seconds together or if I just need to write that in flux.

My Query is the following:
from(bucket: “iobroker”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “Power_Socket_002” or r[“_measurement”] == “Power_Socket_001”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: “mean”)

Thanks for any help on this topic!

I do not have much time, but it appears as two series are being plotted. Try inserting this after the aggregateWindow statement.

  |> pivot(rowKey:["_time"], columnKey: ["_measurement"], valueColumn: "_value")

Edited my original reply. Try inserting after the aggregate window line.

Thanks for the answer!

I tried doing that but that does not seem to change anything. But I am looking closer in the topic of two series being plotted.

I may be wrong, but I believe for your bar chart to show stacked bars (with the time on the x-axis), the two series being plotted must have identical timestamps. This is easy to do in Node-RED. I am not sure was iobroker works or how it sends the data to InfluxDB.

Amazing thanks for the Help!