Mssql query - Unable to stack graph bars by a field

  • What Grafana version and what operating system are you using?
    Grafana v10.4.0

  • What are you trying to achieve?
    I have an SQL query that returns test status by date; I’m trying to stack the bars by date, so I will have a single bar with Failed\Interrupted\Passed(not count of them for each date.

Query:

SELECT
    FORMAT(CAST(tr.StartTime AS DATE), 'yyyy-MM-dd') AS Date,
    tr.Status,
    COUNT(*) AS Count
FROM
    [dbo].[TestResult] tr
INNER JOIN
    [dbo].[TestCase] tc
    ON tr.TestCaseId = tc.Id
INNER JOIN
    [dbo].[Group] g
    ON tc.TeamId = g.Id
WHERE
    $__timeFilter(tr.StartTime)
GROUP BY
    CAST(tr.StartTime AS DATE),
    tr.Status
ORDER BY
    Date,
    tr.Status;

Query result:

2024-11-12	Failed	702
2024-11-12	Interrupted	3
2024-11-12	Passed	1190
2024-11-13	Failed	913
2024-11-13	Interrupted	19
2024-11-13	Passed	2167
2024-11-14	Failed	261
2024-11-14	Passed	987
2024-11-17	Failed	919
2024-11-17	Interrupted	3
2024-11-17	Passed	2704
2024-11-18	Failed	350
2024-11-18	Interrupted	1
2024-11-18	Passed	1930

I set up “Stacking” to “Normal” but couldn’t get them stacked.
I tried to add group by “Date” via “Transform Data” but then I lost the coloring and get “no numeric fields found”

This is the expected:

I found a solution.