# Mssql query - Unable to stack graph bars by a field

**URL:** <https://community.grafana.com/t/mssql-query-unable-to-stack-graph-bars-by-a-field/136617>\
**Category:** Bar Chart Panel\
**Tags:** stacking\
**Created:** [November 19, 2024, 9:14am UTC](https://community.grafana.com/t/mssql-query-unable-to-stack-graph-bars-by-a-field/136617 "2024-11-19T09:14:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matanmalka](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@matanmalka](https://community.grafana.com/u/matanmalka)\
**Post date:** [November 19, 2024, 9:14am UTC](https://community.grafana.com/t/mssql-query-unable-to-stack-graph-bars-by-a-field/136617/1 "2024-11-19T09:14:29Z")

</div>

- 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:

```auto
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:

```auto
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

```

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/2/3/23e8c4a236b9767782280c65121663c46926615f.png)

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:

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/8/8/884e5e301ac1c1a4e97ea7859b718ec91d46c4d9.png)

---

<div class="post-metadata">

**Author:** ![matanmalka](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@matanmalka](https://community.grafana.com/u/matanmalka)\
**Post date:** [November 21, 2024, 7:59am UTC](https://community.grafana.com/t/mssql-query-unable-to-stack-graph-bars-by-a-field/136617/2 "2024-11-21T07:59:43Z")

</div>

I found a solution.

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/3/a/3a8a5677f59f3aed901883ed76005e8c1c5a5e17.png)
