> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# SparklineAgg

This function isn't compatible with all data platform connections. To check if your connection supports it, see [Supported data platforms and feature compatibility](/docs/region-warehouse-and-feature-support#supported-data-platforms-and-feature-compatibility).

The **SparklineAgg** function generates sparkline charts by aggregating values over time. If you want to create sparklines for JSON data, see the [Sparkline](/docs/sparkline) function.

Sparklines can also be created from a column containing pre-formatted data. See [Create sparklines from a table](/docs/create-sparklines-in-a-table).

## Syntax

```
SparklineAgg(category, aggregate)
```

### Function arguments

|               |                                                                                                                        |
| :------------ | :--------------------------------------------------------------------------------------------------------------------- |
| **category**  | The column to be used for the x-axis of the sparkline.                                                                 |
| **aggregate** | The aggregate formula to be used for the y-axis of the sparkline, representing the aggregate of the category argument. |

## Notes

* To create meaningful sparklines, add a grouping to your table. Groupings ensure multiple values are available for use in the sparkline. For more information on groupings, see [Group columns in a table](/docs/create-and-manage-tables#group-columns-in-a-table).
* **SparklineAgg** charts the values provided in the **category** column and returns variant data that renders as a sparkline chart in the table. You cannot copy from the chart canvas.
* To format the chart output of **SparklineAgg** (color, chart type, interpolation, etc), see [Format sparklines](/docs/create-sparklines-in-a-table#format-sparklines) in [Create sparklines in a table](/docs/create-sparklines-in-a-table).

## Example

A table, **PLUGS\_ELECTRONICS\_HANDS\_ON\_LAB\_DATA**, contains information an electronic retailer’s sales, including columns such as:

* *Product Name*: Name of electronic product sold
* *Date*: Date and time of sale transaction
* *Quantity*: Number of a specific product sold during the transaction

To see how the sales of each product have changed month to month, you can use **SparklineAgg**:

1. Group the table by product name. Select + **Add grouping**, then search for and select **Product Name**.
2. Select  + **Add calculation**. In the formula bar, enter:

```
SparklineAgg(DateTrunc("month", [Date]), Sum([Quantity]))
```

Entering `DateTrunc("month", [Date])` as the **category** argument uses the [DateTrunc](/docs/datetrunc) function to truncate the value in the *Date* column to months. These month values form the x-axis of the sparkline. Entering `Sum([Quantity])` as the **aggregate** argument ensures the y-axis reflects the total quantity of products sold in each month.

Your table might look something like:

![Grouped table with a product name column and a sparkline column showing the aggregate sum of quantity sold for each product name by month.](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/a72e2c68ba8ecaafb5efc3801d58212267c12194c19471032d7c5c95a5187dbe/assets/docs-images/a2fec4ff1a67c2152b3ca261552ed204c34ea935361b980a49fda5810e1572d3-sparklineagg_function_image.png)

The sparklines here represent changes in the quantity of each product sold by month.

If you want to change the format (e.g. chart type, color, interpolation) of your sparklines, see [Format sparklines](/docs/create-sparklines-in-a-table#format-sparklines) in [Create sparklines in a table](/docs/create-sparklines-in-a-table).