# Stacking

Stacking refers to combing series values into a single value while retaining their name. It is useful when you want to compare values as part of a whole. Certain chart types support stacking, they are: line, area, column, bar and combo.

<figure><img src="/files/QMG97LKgU1qjURax1soX" alt=""><figcaption></figcaption></figure>

## Adding @stacks

Stacking is enabled for a chart by specifying the `@stacks` directive

```sql
-- @chart: column
-- @title: Stacking - Example column chart with stacking
-- @groups: Month, Channel
-- @subtitle: An example column chart that has a single stack
-- @formats: currency
-- @series: Sales
-- @stacks: Channel
SELECT 
	TRUNC(date_closed, 'MONTH') as Month,
    Channel,
	sum(amount) as Sales
FROM sales
GROUP BY TRUNC(date_closed, 'MONTH'), Channel
ORDER BY TRUNC(date_closed, 'MONTH') ASC;
```

## Stacking Examples

<table data-card-size="large" data-view="cards"><thead><tr><th data-card-target data-type="content-ref"></th><th data-hidden></th><th data-hidden></th><th data-hidden></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><a href="/pages/N6Jr8TfhmU6pCqG1xGgL#area-chart-with-100-stacking">/pages/N6Jr8TfhmU6pCqG1xGgL#area-chart-with-100-stacking</a></td><td></td><td></td><td></td><td><a href="/files/01OUSfXiKmOIQphqIwpT">/files/01OUSfXiKmOIQphqIwpT</a></td></tr><tr><td><a href="/pages/Fp7IYM3hpnOOOno6DMLq#stacked-column">/pages/Fp7IYM3hpnOOOno6DMLq#stacked-column</a></td><td></td><td></td><td></td><td><a href="/files/QMG97LKgU1qjURax1soX">/files/QMG97LKgU1qjURax1soX</a></td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chartsql.com/chartsql-studio/creating-charts/stacking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
