# Stacking bar in barchart

**URL:** <https://community.grafana.com/t/stacking-bar-in-barchart/109391>\
**Category:** Dashboards\
**Created:** [December 6, 2023, 5:12am UTC](https://community.grafana.com/t/stacking-bar-in-barchart/109391 "2023-12-06T05:12:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaymalodoi](https://avatars.discourse-cdn.com/v4/letter/j/3e96dc/32.png) [@jaymalodoi](https://community.grafana.com/u/jaymalodoi)\
**Post date:** [December 6, 2023, 5:12am UTC](https://community.grafana.com/t/stacking-bar-in-barchart/109391/1 "2023-12-06T05:12:32Z")

</div>

Hello,

I’m pretty new to Grafana and Data Base manipulation. I’m trying to create a BarCharts which represent the amount of parts produced for each Parts Type. I need to stack the bar and I can’t find a solution to do it

- What Grafana version and what operating system are you using?  
v9.4.10

- **What** are you trying to achieve?  
Stack bar in a Bar Charts.

- **How** are you trying to achieve it?  
That’s the question

- What happened?  
Impossible to find a solution to stack bar. Here is my result for now :  

- What did you **expect** to happen?  
Exemple here made with Excel :  

- Can you copy/paste the configuration(s) that you are having problems with?

`DECLARE @start DATETIME  
DECLARE @end DATETIME  
DECLARE @offsetDay INT = 0

IF (SELECT DATEPART(weekday,GETDATE())) = 1  
SET @offsetDay = -2

SET @start = (SELECT DATEADD(dd, @offsetDay, DATEDIFF(dd, 0, GETDATE())))  
SET @start = (SELECT DATEADD(hh,-19, @start))

SET @end = (SELECT DATEADD(dd, @offsetDay, DATEDIFF(dd, 0, GETDATE())))  
SET @end = (SELECT DATEADD(hh,5,@end))

SELECT  
TypeID,  
COUNT(\*) as Real\_Prod  
FROM  
L7DAE.dbo.OP7300  
WHERE  
LeaveDate BETWEEN @start AND @end  
AND PartState = 1  
GROUP BY  
TypeId  
ORDER BY MIN(LeaveDate) ASC `

- Did you receive any errors in the Grafana UI or in related logs? If so, please tell us **exactly** what they were.  
No
- Did you follow any online instructions? If so, what is the URL?  
No

Thanks in advance for your help !

---

<div class="post-metadata">

**Author:** ![sowdenraymond](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/sowdenraymond/32/38541_2.png) [@sowdenraymond](https://community.grafana.com/u/sowdenraymond)\
**Post date:** [December 6, 2023, 8:02am UTC](https://community.grafana.com/t/stacking-bar-in-barchart/109391/2 "2023-12-06T08:02:08Z")

</div>

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