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?



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

Below is my data in csv

Government Jobs,15,“Bhopal”,“2010”
Government Jobs,6,“Bhopal”,“2015”
Government Jobs,34,“Bhopal”,“2020”

I want to write this data in influxdb and then visualise it in grafana. I want to display a bar chart which should display all the type of jobs
and its corresponding vacancy in stacked bar chart for a particular year. i.e. x axis should be year and y axis will contain the total vacancy for a particular year. for example the first bar should represent the different vacancy in stacked available for year 2010.

Currently i am getting a below chart. but I am not able to stack them.