Stacked Bar Chart Help

What I need to do is create a Bar Chart for a hotel with the x-axis being different floors, y axis being power used, and the height of a bar representing the sum of all power used on a particular floor. However, what I want is for each floor’s bar to really be the combination of stacking each individual room’s bar on top of one another. That is, in order to find room x’s “segment on its floor’s bar”, I would sum all power demands of all floors from 1 to x-1 and then add x and that would be room x’s bar. When I do this for all rooms and overlap, it should look like one big bar chopped up.

Rather than creating a query for each room (there are an insanely large number of rooms) I was wondering if something like a for loop exists in influx that can iterate for me. If that doesn’t exist (and neither some other replacement), would my only path be hard querying every room? P.S. I’m new to Grafana and trying to utilize its great functionality by navigating its intricacies :slight_smile:

That’s exactly it, what did you write to stack the room values?

Stacking

image

from(bucket: "hotel_motel")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "power_usage")
  |> filter(fn: (r) => r["_field"] == "Floor" or r["_field"] == "Room1" or r["_field"] == "Room2" or r["_field"] == "Room3" or r["_field"] == "Room4")
  |> filter(fn: (r) => r["tag1"] == "powa")
1 Like

But the above is problematic if 1000 rooms