﻿---
title: ES|QL VARIANCE_OVER_TIME function
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/3028/reference/query-languages/esql/functions-operators/time-series-aggregation-functions/variance_over_time
products:
  - Elasticsearch
---

# ES|QL VARIANCE_OVER_TIME function
<applies-to>
  - Elastic Cloud Serverless: Preview
  - Elastic Stack: Preview since 9.3
</applies-to>


## Syntax

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


## Parameters

<definitions>
  <definition term="field">
    the metric field to calculate the value for
  </definition>
  <definition term="window">
    the time window over which to compute the variance over time
  </definition>
</definitions>


## Description

Calculates the population variance over time of a numeric field.

## Supported types


| field   | window                                                                  | result |
|---------|-------------------------------------------------------------------------|--------|
| double  | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |
| integer | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |
| long    | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |


## Example

```esql
TS k8s
| STATS avg_var_cost=AVG(VARIANCE_OVER_TIME(network.cost)) BY cluster, time_bucket = TBUCKET(1minute)
```


| cluster:keyword | time_bucket:datetime     | avg_var_cost:double |
|-----------------|--------------------------|---------------------|
| staging         | 2024-05-10T00:03:00.000Z | 20.478516           |
| qa              | 2024-05-10T00:21:00.000Z | 16.0                |
| qa              | 2024-05-10T00:18:00.000Z | 11.192274           |
| staging         | 2024-05-10T00:09:00.000Z | 10.446904           |