# MOVINGAVERAGE

The MOVINGAVERAGE formula returns the average of a measure over a specified date range.&#x20;

## Syntax

```javascript
MOVINGAVERAGE(measure, startDate, endDate)
```

## Arguments

measure– The measure to sum. Required.

startDate – Start date of the range. Required.

endDate- End date of the range. Required.

## Return value

Returns the average of the measure over the specified date range.

## Example

```javascript
MOVINGAVERAGE([Profit], CURRENT_PERIOD, SHIFT(CURRENT_PERIOD, "2M"))
//Calculates the sum of the profit for a particular month and 2 months after it

MOVINGAVERAGE([Sales], DATE(2024,4,1), DATE(2024,8,31))
//Calculates the rolling average between April and August 2024 
```

We've used MOVINGAVERAGE to calculate the rolling average of the profit measure for each month and 2 months after that month. For example, the MOVINGAVERAGE for January would be the average of the profits for January, February, and March.

<figure><img src="/files/s7NDtPKiH7iUMAG3xkpe" alt=""><figcaption><p>MOVINGAVG</p></figcaption></figure>

You can also use MOVINGAVERAGE with forecasts to aggregate your measures over open and closed periods. In this example, we've aggregated the forecast measure for the open periods.

<figure><img src="/files/4shfWQcSh6Q4Dr7895aH" alt=""><figcaption><p>MOVINGAVERAGE</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.inforiver.com/formula-syntax/time-intelligence-functions/movingaverage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
