﻿---
title: ES|QL CHANGES function
description: 
url: https://docs-v3-preview.elastic.dev/elastic/elasticsearch/tree/main/reference/query-languages/esql/functions-operators/time-series-aggregation-functions/changes
products:
  - Elasticsearch
---

# ES|QL CHANGES function
<applies-to>
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Planned
</applies-to>

Calculates the number of value changes in a time window.

## Syntax

![Embedded](https://docs-v3-preview.elastic.dev/elastic/elasticsearch/tree/main/reference/query-languages/esql/images/generated/x-pack-esql/functions/changes.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 changes
  </definition>
</definitions>


## Description

Calculates the number of times the value of a numeric or native histogram metric field changes in a time window.

## Supported types


| field                 | window                                                        | result |
|-----------------------|---------------------------------------------------------------|--------|
| counter_double        | time_duration <applies-to>Elastic Stack: Planned</applies-to> | long   |
| counter_integer       | time_duration <applies-to>Elastic Stack: Planned</applies-to> | long   |
| counter_long          | time_duration <applies-to>Elastic Stack: Planned</applies-to> | long   |
| double                | time_duration <applies-to>Elastic Stack: Planned</applies-to> | long   |
| exponential_histogram | time_duration <applies-to>Elastic Stack: Planned</applies-to> | long   |
| integer               | time_duration <applies-to>Elastic Stack: Planned</applies-to> | long   |
| long                  | time_duration <applies-to>Elastic Stack: Planned</applies-to> | long   |


## Example

```esql
TS k8s
| STATS cost_changes = SUM(CHANGES(network.cost)) BY time_bucket = TBUCKET(1 minute)
```


| cost_changes:long | time_bucket:datetime     |
|-------------------|--------------------------|
| 1                 | 2024-05-10T00:00:00.000Z |
| 0                 | 2024-05-10T00:01:00.000Z |
| 2                 | 2024-05-10T00:02:00.000Z |