﻿---
title: ES|QL SPARKLINE function
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/3007/reference/query-languages/esql/functions-operators/aggregation-functions/sparkline
products:
  - Elasticsearch
---

# ES|QL SPARKLINE function
<applies-to>
  - Elastic Cloud Serverless: Preview
  - Elastic Stack: Planned
</applies-to>


## Syntax

![Embedded](https://www.elastic.co/elastic/docs-builder/docs/3007/reference/query-languages/esql/images/functions/sparkline.svg)


## Parameters

<definitions>
  <definition term="field">
    Expression that calculates the y-axis value of the sparkline graph for each datapoint.
  </definition>
  <definition term="key">
    Date expression from which to derive buckets.
  </definition>
  <definition term="buckets">
    Target number of buckets, or desired bucket size if `from` and `to` parameters are omitted.
  </definition>
  <definition term="from">
    Start of the range. Can be a date or a date expressed as a string.
  </definition>
  <definition term="to">
    End of the range. Can be a date or a date expressed as a string.
  </definition>
</definitions>


## Description

The values representing the y-axis values of a sparkline graph for a given aggregation over a period of time.

## Supported types


| field   | key  | buckets | from    | to      | result  |
|---------|------|---------|---------|---------|---------|
| double  | date | integer | text    | text    | double  |
| integer | date | integer | date    | date    | integer |
| long    | date | integer | keyword | keyword | long    |


## Example

```esql
FROM employees
| STATS sparkline = SPARKLINE(COUNT(*), hire_date, 20, "1985-01-01T00:00:00Z", "1985-12-31T00:00:00Z")
```


| sparkline:long                       |
|--------------------------------------|
| [0, 2, 0, 0, 1, 0, 1, 0, 1, 2, 4, 0] |