# Calculate the rate of change

Use `derivative()` to calculate the rate of change between subsequent values or `aggregate.rate()` to calculate the average rate of change per window of time. If time between points varies, these functions normalize points to a common time interval making values easily comparable.

## Rate of change between subsequent values

Use the `derivative()` function to calculate the rate of change per unit of time between subsequent non-null values.

``````data
|> derivative(unit: 1s)
``````

By default, `derivative()` returns only positive derivative values and replaces negative values with null. Calculated values are returned as floats.

Given the following input:

_time_value
2020-01-01T00:00:00Z250
2020-01-01T00:04:00Z160
2020-01-01T00:12:00Z150
2020-01-01T00:19:00Z220
2020-01-01T00:32:00Z200
2020-01-01T00:51:00Z290
2020-01-01T01:00:00Z340

`derivative(unit: 1m)` returns:

_time_value
2020-01-01T00:04:00Z
2020-01-01T00:12:00Z
2020-01-01T00:19:00Z10.0
2020-01-01T00:32:00Z
2020-01-01T00:51:00Z4.74
2020-01-01T01:00:00Z5.56

Results represent the rate of change per minute between subsequent values with negative values set to null.

### Return negative derivative values

To return negative derivative values, set the `nonNegative` parameter to `false`,

Given the following input:

_time_value
2020-01-01T00:00:00Z250
2020-01-01T00:04:00Z160
2020-01-01T00:12:00Z150
2020-01-01T00:19:00Z220
2020-01-01T00:32:00Z200
2020-01-01T00:51:00Z290
2020-01-01T01:00:00Z340

The following returns:

``````|> derivative(unit: 1m, nonNegative: false)
``````
_time_value
2020-01-01T00:04:00Z-22.5
2020-01-01T00:12:00Z-1.25
2020-01-01T00:19:00Z10.0
2020-01-01T00:32:00Z-1.54
2020-01-01T00:51:00Z4.74
2020-01-01T01:00:00Z5.56

Results represent the rate of change per minute between subsequent values and include negative values.

## Average rate of change per window of time

Use the `aggregate.rate()` function to calculate the average rate of change per window of time.

``````import "experimental/aggregate"

data
|> aggregate.rate(
every: 1m,
unit: 1s,
groupColumns: ["tag1", "tag2"],
)
``````

`aggregate.rate()` returns the average rate of change (as a float) per `unit` for time intervals defined by `every`. Negative values are replaced with null.

`aggregate.rate()` does not support `nonNegative: false`.

Given the following input:

_time_value
2020-01-01T00:00:00Z250
2020-01-01T00:04:00Z160
2020-01-01T00:12:00Z150
2020-01-01T00:19:00Z220
2020-01-01T00:32:00Z200
2020-01-01T00:51:00Z290
2020-01-01T01:00:00Z340

The following returns:

``````|> aggregate.rate(
every: 20m,
unit: 1m,
)
``````
_time_value
2020-01-01T00:20:00Z10.00
2020-01-01T00:40:00Z
2020-01-01T01:00:00Z4.74
2020-01-01T01:20:00Z5.56

Results represent the average change rate per minute of every 20 minute interval with negative values set to null. Timestamps represent the right bound of the time window used to average values.

### Introducing InfluxDB Clustered

A highly available InfluxDB 3.0 cluster on your own infrastructure.

InfluxDB Clustered is a highly available InfluxDB 3.0 cluster built for high write and query workloads on your own infrastructure.

InfluxDB Clustered is currently in limited availability and is only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

### The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following:

### State of the InfluxDB Cloud Serverless documentation

InfluxDB Cloud Serverless documentation is a work in progress.

The new documentation for InfluxDB Cloud Serverless is a work in progress. We are adding new information and content almost daily. Thank you for your patience!

If there is specific information you’re looking for, please submit a documentation issue.