> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# MovingMax

> Use the Sigma MovingMax function to find the maximum value of a column within a moving window.

The **MovingMax** function finds the maximum value of a column within a moving window.

## Syntax

```
MovingMax([Column], above, below)
```

Function Arguments:

* **\[Column]** (required) - The column to be searched.
* **above** (required) - The first row to include, counting backward from the current row.
* **below** (optional) - The last row to include, counting forward from the current row. Defaults to 0 (current row will be the last row included).

When using this function without a sort enforced, there can be unexpected results. In order to ensure that the values are stable, verify that there is a sorted column within the table.

## Example

A table lists the weekly sales for the past year. The table is sorted ascending by the week. The **MovingMax** function can be utilized in order to find the maximum value within specific windows.

```
MovingMax([Weekly Sales], 4)
```

With \[Weekly Sales] as the **column** argument and 4 as the **above** argument, the maximum weekly sales value is calculated for each week along with the four previous weeks. Since the **below** argument is not specified, it defaults to 0.  

![A table with Week of Date, Weekly Sales, and MovingMax of Weekly Sales columns, highlighting the current week and four previous weeks of sales that produce a moving maximum of \$13,604,708.90 for the week of 2022-09-11.](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/dc5b7dd02d8ce06825f2cf83567b71e477587be8536afcc6dd5bd95018132abe/assets/docs-images/58c13fc-1.png)

```
MovingMax([Weekly Sales], 0, 4)
```

Here, the **above** argument is 0, so no previous weeks are included in the maximum calculation. The **below** average is 4, so the maximum weekly sales value is computed for each week along with the next 4 weeks.

![A table with Week of Date, Weekly Sales, and MovingMax of Weekly Sales columns, highlighting the week of 2022-08-14 and the next four weeks of sales, which produce a moving maximum of \$13,604,708.90 for that week.](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/8f5ae87face39617764ed740ea61647459560b3a39942953111e8e1742e218b7/assets/docs-images/20657c1-2.png)

```
MovingMax([Weekly Sales], 2, 2)
```

Here, the **above** argument is 2, so the previous two weeks are included in the maximum calculation. In addition, the **below** argument is 2, so the following two weeks are included as well.

![A table with Week of Date, Weekly Sales, and MovingMax of Weekly Sales columns, highlighting the two weeks before and after 2022-08-28, which produce a moving maximum of \$13,604,708.90 for that week.](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/ff74d9b9c04b141caa030086ada01d4ecb7c4846b6992ddd504696761feb8e97/assets/docs-images/4d46f09-3.png)

```
MovingMax([Weekly Sales], 8, -4)
```

Here is an example where the **below** parameter is negative. The **below** parameter can be negative as long as the value is less than that of the **above** parameter. In this example, each window begins 8 weeks before the current week and ends 4 weeks before the current week, inclusive.

![A table with Week of Date, Weekly Sales, and MovingMax of Weekly Sales columns, highlighting the window from eight to four weeks before 2022-10-09, which produces a moving maximum of \$13,604,708.90 for that week.](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/4740a1d7c5f481a3bdcfe15c2638998df889f056a5afce4f8c88c17f151c5998/assets/docs-images/6b7830b-4.png)

## Related resources

* [CumulativeMax](/docs/cumulativemax)
* [Max](/docs/max)
* [MovingMin](/docs/movingmin)