Unable to Stack Graph Bars by Field Values in Grafana

What Grafana version and what operating system are you using?
Grafana v11.3.0 on MacOS 15.1

What are you trying to achieve?
I’m trying to create a stacked bar chart where unique values on the bucket field are displayed along the x-axis, and different channel values for each bucket are stacked on top of each other.

How are you trying to achieve it?
I’m running a query against a Prometheus data source that returns metric points with three fields:
sum by(bucket, channel) (cdh_nba_optionality_requests_total{instance=~"$instance", direction="Inbound", subject_type="all_subject_types", strategy=~"$strategy"})
bucket, channel, and metric count. I want to configure the panel to display unique bucket values on the x-axis, with each channel stacked within its corresponding bucket.

What happened?
Currently, the graph is duplicating the bucket values along the x-axis instead of stacking them. Each channel is represented as a separate bar next to other bars of the same bucket value, rather than stacking within the same bucket.

What did you expect to happen?
I expected the graph to show each bucket value only once on the x-axis, with the channel values stacked on top of each other within that bucket.

Images:
Current graph showing duplicated bucket values on the x-axis.

The table view of the same data.

Other transformations applied on the chart:

i don’t think that’s how stacking works, it’s not a prometheus data source problem

So i have updated the title of the problem based on your comment. But i would still like to know how we can get it to show the way I want it to stack. Is it not possible to do this in Grafana? Or is there another way to do this?

https://play.grafana.org/d/timeseries-stacking2/timeseries-and-barchart-stacking?orgId=1&from=2021-12-14T04:26:06.000Z&to=2022-01-19T08:44:05.000Z&editPanel=39

Thanks for the pointer. I added a new transformation to achieve this as shown below: