Unable to create a stacked bar chart

  • What Grafana version and what operating system are you using?
    Grafana v10.4.3 running in a docker container with Postgres db

  • What are you trying to achieve?
    I want to create a dashboard with specific stacked bar data in the bar chart.

  • How are you trying to achieve it?

I have the following query:

SELECT
    EXTRACT(YEAR FROM dividend_date)::TEXT AS year,
    p.symbol AS position,
    SUM(d.dividend_received) AS total_dividends
FROM
    "Dividend" d
JOIN
    "Positions" p ON d.symbol_id = p.id
GROUP BY
    year, position
ORDER BY
    year, position;

Which returns the following data:

2008	AAPL	0.57
2009	GOOG	0.27
2009	AAPL	1.05
2009	TESLA	1.01
2010	GOOG	0.28
2010	AAPL	0.81
2010	TESLA	0.89

... and more
  • What happened?
    I see all of them with the same color and they are not stacked

  • What did you expect to happen?
    Iā€™d like to have them stacked or grouped by year as well with different colors

perfect! it is working like a charm, thanks!

1 Like