> For the complete documentation index, see [llms.txt](https://docs.chartsql.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chartsql.com/charts/column.md).

# Column

Column charts show numerical values across categories

<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="/charts/column.md#basic-column-chart">Column</a></td><td></td><td></td><td></td><td><a href="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2Fw4NfQO97MBsLQcjFou3a%2Fbasic_column_example.jpg?alt=media&amp;token=f324f552-5a3f-4e88-8e4c-c78dbc953902">basic_column_example.jpg</a></td></tr><tr><td><a href="/charts/column.md#stacked-column">Column</a></td><td></td><td></td><td></td><td><a href="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2FC1DVRbn2hnMiubOgRNUx%2Fimage.png?alt=media&amp;token=8af3f877-2e61-4fdc-b3d3-b6454901680c">stacking_example.png</a></td></tr><tr><td><a href="/charts/column.md#column-with-series-labels">Column</a></td><td></td><td></td><td></td><td><a href="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2FJnAvKK20WpWux7qvofaC%2Fimage.png?alt=media&amp;token=6d554797-0c2b-4166-8e21-2d4ca263b64d">series-labels-example.png</a></td></tr><tr><td><a href="/charts/column.md#auto-grouped-column">Column</a></td><td></td><td></td><td></td><td><a href="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2Fkg51oG28dcfRiX04pKHT%2Fauto_grouped_column_example.jpg?alt=media&amp;token=3f9c625f-f506-439e-83d9-6a886c539d50">auto_grouped_column_example.jpg</a></td></tr><tr><td><a href="/charts/column.md#column-with-single-baseline">Column</a></td><td></td><td></td><td></td><td><a href="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2Fs9YtqpyCAKVfmzMEKAYn%2Fbaselines_example.jpg?alt=media&amp;token=0d0eb41a-1e8e-42b5-96f7-3fe7dfd5fd9c">baselines_example.jpg</a></td></tr><tr><td><a href="/charts/column.md#column-with-multiple-baselines-for-one-series">Column</a></td><td></td><td></td><td></td><td><a href="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2F6J8L7maSfdf5TVfGcRQ2%2Fbaseline-types_example.jpg?alt=media&amp;token=45123e20-e50c-4874-be1f-122f84f72eeb">baseline-types_example.jpg</a></td></tr><tr><td><a href="/charts/column.md#column-with-commented-out-directive">Column</a></td><td></td><td></td><td></td><td><a href="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2F8rhX7dMWF6dL8u2FkPuG%2Fimage.png?alt=media&amp;token=353eaa2f-98eb-42a5-bbc0-6c6468bc3caa">commented_out_directive_example.png</a></td></tr><tr><td><a href="/charts/column.md#auto-column">Column</a></td><td></td><td></td><td></td><td><a href="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2FQUDhuS6lvAOujjXSZjuU%2Fimage.png?alt=media&amp;token=9ff8ec3d-9d77-4f42-81cf-9c590db3edce">auto_column_example.png</a></td></tr><tr><td><a href="/charts/column.md#column-with-explicit-series">Column</a></td><td></td><td></td><td></td><td><a href="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2F9cNMNdDfTYpOrZBrvSfq%2Fimage.png?alt=media&amp;token=c934c3dc-4591-4982-9174-8c54eaca3c9a">column_example_with_explicit_series.png</a></td></tr></tbody></table>

## Basic Column Chart

```sql
-- @chart: column
-- @title: Column - Basic Column Chart
-- @subtitle: An example column chart showing sales by month
-- @formats: currency
SELECT 
	TRUNC(date_closed, 'MONTH') as Month,
	sum(amount) as Sales
FROM sales
GROUP BY Month
ORDER BY Month ASC;
```

<figure><img src="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2Fw4NfQO97MBsLQcjFou3a%2Fbasic_column_example.jpg?alt=media&amp;token=f324f552-5a3f-4e88-8e4c-c78dbc953902" alt=""><figcaption></figcaption></figure>

| MONTH                            | SALES     |
| -------------------------------- | --------- |
| January, 01 2017 00:00:00 +0000  | 2668855.0 |
| February, 01 2017 00:00:00 +0000 | 3951547.0 |
| March, 01 2017 00:00:00 +0000    | 4403443.0 |
| April, 01 2017 00:00:00 +0000    | 3079040.0 |
| May, 01 2017 00:00:00 +0000      | 2576305.0 |
| June, 01 2017 00:00:00 +0000     | 3100093.0 |

## Stacked Column

```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 Month, Channel
ORDER BY Month ASC;
```

<figure><img src="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2FC1DVRbn2hnMiubOgRNUx%2Fimage.png?alt=media&amp;token=8af3f877-2e61-4fdc-b3d3-b6454901680c" alt=""><figcaption><p>An example of a stacked column chart</p></figcaption></figure>

| MONTH                            | CHANNEL  | SALES     |
| -------------------------------- | -------- | --------- |
| January, 01 2017 00:00:00 +0000  | coldcall | 174647.0  |
| January, 01 2017 00:00:00 +0000  | referral | 1310064.0 |
| January, 01 2017 00:00:00 +0000  | search   | 681444.0  |
| January, 01 2017 00:00:00 +0000  | event    | 502700.0  |
| February, 01 2017 00:00:00 +0000 | pr\_ad   | 509564.0  |
| February, 01 2017 00:00:00 +0000 | search   | 1109141.0 |
| February, 01 2017 00:00:00 +0000 | event    | 417651.0  |

## Column with Series Labels

```sql
-- @chart: column
-- @title: Series Labels - Label at Top of Series
-- @subtitle: An example column chart with a series label above the top
-- @formats: currency
-- @series-labels: top
SELECT 
	TRUNC(date_closed, 'MONTH') as Month,
	sum(amount) as Sales
FROM sales
-- Select just 1 year so that the labels are not too cluttered
WHERE year(date_closed) = 2017
GROUP BY Month
ORDER BY Month ASC;
```

<figure><img src="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2FJnAvKK20WpWux7qvofaC%2Fimage.png?alt=media&amp;token=6d554797-0c2b-4166-8e21-2d4ca263b64d" alt=""><figcaption><p>An example column chart with series labels</p></figcaption></figure>

| MONTH                             | SALES     |
| --------------------------------- | --------- |
| January, 01 2017 00:00:00 +0000   | 2668855.0 |
| February, 01 2017 00:00:00 +0000  | 3951547.0 |
| March, 01 2017 00:00:00 +0000     | 4403443.0 |
| April, 01 2017 00:00:00 +0000     | 3079040.0 |
| May, 01 2017 00:00:00 +0000       | 2576305.0 |
| June, 01 2017 00:00:00 +0000      | 3100093.0 |
| July, 01 2017 00:00:00 +0000      | 3112476.0 |
| August, 01 2017 00:00:00 +0000    | 4980193.0 |
| September, 01 2017 00:00:00 +0000 | 4335105.0 |
| October, 01 2017 00:00:00 +0000   | 3552154.0 |
| November, 01 2017 00:00:00 +0000  | 3426988.0 |
| December, 01 2017 00:00:00 +0000  | 3761158.0 |

## Auto Grouped Column

When 1 string columns and 2 numeric columns exist

```sql
-- @title: Auto Grouped Column
-- @subtitle: Auto grouping columns when there is one category and two values
SELECT 
	Channel,
	SUM(
      CASE WHEN Sales.Status = 'Won' OR Sales.Status = 'Lost' THEN 1 ELSE 0 END
    ) as "Sales_Closed",
    SUM(
      CASE WHEN Sales.Status = 'Won' THEN 1 ELSE 0 END
    ) as "Sales_Won"
FROM sales
GROUP BY Channel;
```

<figure><img src="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2Fkg51oG28dcfRiX04pKHT%2Fauto_grouped_column_example.jpg?alt=media&amp;token=3f9c625f-f506-439e-83d9-6a886c539d50" alt=""><figcaption><p>An example of columns being automatically grouped</p></figcaption></figure>

| CHANNEL  | SALES\_CLOSED | SALES\_WON |
| -------- | ------------- | ---------- |
| coldcall | 206.0         | 37.0       |
| referral | 1069.0        | 243.0      |
| search   | 344.0         | 66.0       |
| event    | 427.0         | 112.0      |
| pr\_ad   | 110.0         | 21.0       |

## Column with Single Baseline

```sql
-- @chart: column
-- @title: Baselines - Single Baseline
-- @subtitle: An example column chart with a default average baseline
-- @baselines: Sales
-- @series: SALES
-- @formats: currency
SELECT 
	TRUNC(date_closed, 'MONTH') as Month,
	sum(amount) as Sales
FROM sales
GROUP BY Month
ORDER BY Month ASC;
```

<figure><img src="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2Fs9YtqpyCAKVfmzMEKAYn%2Fbaselines_example.jpg?alt=media&amp;token=0d0eb41a-1e8e-42b5-96f7-3fe7dfd5fd9c" alt=""><figcaption><p>An example column chart wtih a baseline </p></figcaption></figure>

| MONTH                            | SALES     |
| -------------------------------- | --------- |
| January, 01 2017 00:00:00 +0000  | 2668855.0 |
| February, 01 2017 00:00:00 +0000 | 3951547.0 |
| March, 01 2017 00:00:00 +0000    | 4403443.0 |
| April, 01 2017 00:00:00 +0000    | 3079040.0 |
| May, 01 2017 00:00:00 +0000      | 2576305.0 |

## Column with Multiple Baselines for one Series

```sql
-- @chart: column
-- @title: Baselines - Multiple Baseline for one series
-- @subtitle: An example column chart showing sales by month
-- @formats: currency
-- @series: Sales
-- @baselines: Sales, Sales, Sales
-- @baseline-types: average, min, max
SELECT 
	TRUNC(date_closed, 'MONTH') as Month,
	sum(amount) as Sales
FROM sales
GROUP BY Month
ORDER BY Month ASC;
```

<figure><img src="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2F6J8L7maSfdf5TVfGcRQ2%2Fbaseline-types_example.jpg?alt=media&amp;token=45123e20-e50c-4874-be1f-122f84f72eeb" alt=""><figcaption><p>An exmaple column chart with multiple baselines</p></figcaption></figure>

| MONTH                            | SALES     |
| -------------------------------- | --------- |
| January, 01 2017 00:00:00 +0000  | 2668855.0 |
| February, 01 2017 00:00:00 +0000 | 3951547.0 |
| March, 01 2017 00:00:00 +0000    | 4403443.0 |
| April, 01 2017 00:00:00 +0000    | 3079040.0 |
| May, 01 2017 00:00:00 +0000      | 2576305.0 |
| June, 01 2017 00:00:00 +0000     | 3100093.0 |
| July, 01 2017 00:00:00 +0000     | 3112476.0 |

## Column with Commented out Directive

```sql
-- @chart: column
-- @title: Directive Comments
-- @subtitle: An example of commenting out a directive
-- @formats: currency
-- @series: Sales
-- //@baselines: Sales
SELECT 
	TRUNC(date_closed, 'MONTH') as Month,
	sum(amount) as Sales
FROM sales
GROUP BY Month
ORDER BY Month ASC;
```

<figure><img src="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2F8rhX7dMWF6dL8u2FkPuG%2Fimage.png?alt=media&amp;token=353eaa2f-98eb-42a5-bbc0-6c6468bc3caa" alt=""><figcaption><p>An example chart with @baselines commented out</p></figcaption></figure>

| MONTH                            | SALES     |
| -------------------------------- | --------- |
| January, 01 2017 00:00:00 +0000  | 2668855.0 |
| February, 01 2017 00:00:00 +0000 | 3951547.0 |
| March, 01 2017 00:00:00 +0000    | 4403443.0 |
| April, 01 2017 00:00:00 +0000    | 3079040.0 |
| May, 01 2017 00:00:00 +0000      | 2576305.0 |
| June, 01 2017 00:00:00 +0000     | 3100093.0 |

## Auto Column

```sql
-- @title: Auto Column
-- @subtitle: An example of an auto selected column chart
SELECT 
Channel,
count(*) as Won_Sales
FROM Sales
WHERE Status = 'Won'
GROUP BY Channel;
```

<figure><img src="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2FQUDhuS6lvAOujjXSZjuU%2Fimage.png?alt=media&amp;token=9ff8ec3d-9d77-4f42-81cf-9c590db3edce" alt=""><figcaption><p>An example of an auto selected column chat</p></figcaption></figure>

| CHANNEL  | WON\_SALES |
| -------- | ---------- |
| search   | 66.0       |
| coldcall | 37.0       |
| event    | 112.0      |
| referral | 243.0      |
| pr\_ad   | 21.0       |

## Column with Explicit Series

There are multiple columns defined, but we are only picking a specieis series using the `@series` directive:

```sql
-- @chart: column
-- @title: Series - Basic chart
-- @subtitle: An example of explicitly defining the series
-- @series: Sales
-- @formats: currency
SELECT 
	TRUNC(date_closed, 'MONTH') as Month,
	sum(amount) as Sales,
    sum(Profit) as Profit
FROM sales
GROUP BY Month
ORDER BY Month ASC;
```

<figure><img src="https://4045370218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0xzzR5x0BnQ6kHixlzd%2Fuploads%2F9cNMNdDfTYpOrZBrvSfq%2Fimage.png?alt=media&amp;token=c934c3dc-4591-4982-9174-8c54eaca3c9a" alt=""><figcaption><p>An example column chart wtih more than one column but only a specific series defined</p></figcaption></figure>

| MONTH                            | SALES     | PROFIT    |
| -------------------------------- | --------- | --------- |
| January, 01 2017 00:00:00 +0000  | 2668855.0 | 801583.0  |
| February, 01 2017 00:00:00 +0000 | 3951547.0 | 1117761.0 |
| March, 01 2017 00:00:00 +0000    | 4403443.0 | 1224108.0 |
| April, 01 2017 00:00:00 +0000    | 3079040.0 | 862533.0  |
| May, 01 2017 00:00:00 +0000      | 2576305.0 | 631699.0  |
| June, 01 2017 00:00:00 +0000     | 3100093.0 | 870893.0  |
| July, 01 2017 00:00:00 +0000     | 3112476.0 | 871875.0  |

### Heading2
