# Baselines

ChartSQL introduces baseline marks/lines to add context and reference points to chart visualizations. These lines represent significant values such as the average, min, max, median of a series. Baselines provide visual cues for comparison against a common or target value.

See [Baselines](/charts/formatting-and-rendering/baselines.md) examples and the [@baselines](/reference/directives/baselines.md) and [@baseline-types](/reference/directives/baseline-types.md) directives.

```sql
-- @chart: column
-- @title: Baselines - Average Baseline
-- @subtitle: An example column chart showing sales by month
-- @formats: currency
-- @series: Sales
-- @baselines: Sales
SELECT 
	TRUNC(date_closed, 'MONTH') as Month,
	sum(amount) as Sales
FROM sales
GROUP BY TRUNC(date_closed, 'MONTH')
ORDER BY TRUNC(date_closed, 'MONTH') ASC
```

<figure><img src="/files/gwKyBu3l6WXw4tYFqzrc" alt=""><figcaption><p>An example column chart with a baseline</p></figcaption></figure>

## Baseline Directives Overview

* `@baselines`: Specifies the series to which baselines are applied and indicates the presence of baseline lines in the chart.
* `@baseline-types` (optional): Sets the type of baselines on the specified series. If omitted, the default type, 'average', is applied. Supported types include: 'average', 'min', 'max', or 'median'

## Examples

A column chart showcasing average sales with a baseline for the average value:

```sql
-- @chart: column
-- @title: Baselines - Average Baseline
-- @subtitle: An example column chart showing sales by month
-- @formats: currency
-- @series: Sales
-- @baselines: Sales
SELECT 
	TRUNC(date_closed, 'MONTH') as Month,
	sum(amount) as Sales
FROM sales
GROUP BY TRUNC(date_closed, 'MONTH')
ORDER BY TRUNC(date_closed, 'MONTH') ASC
```

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

A chart with multiple baselines with specified types:

```sql
-- @chart: column
-- @title: Baselines - Multiple Baseline Types on 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 TRUNC(date_closed, 'MONTH')
ORDER BY TRUNC(date_closed, 'MONTH') ASC
```

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

## Default Behavior

Without specifying types or labels, baselines default to drawing an 'average' line across the specified series in the chart.


---

# 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/baselines.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.
