# Moving average

This Moving average step smooths out short-term fluctuations in your data by calculating averages over a specified window of time or number of rows. It's particularly helpful for identifying trends in time-series data.

### Step parameters

* `Value column` **column(string)**: the value column used as the basis for the moving average computation
* `Reference column to sort (usually dates)` **column(string)**: the column used to sort rows
* `Moving window (in number of rows)` **int\***: the number of rows included in the moving window
* `Group by` **(optional)**: if you want perform the computation by group of rows (see example 2 below)
* `New column name` **(optional)**: if you want to specify a custom column name (by default, it will be your original value column name suffixed with `_MOVING_AVG`)

### Example

**Input**

<figure><img src="https://1809014303-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZxYYf1KpgarKMgMsDCrw%2Fuploads%2Fgit-blob-adf61b42b0d20ee337aabaab141d74406f6e6596%2Fmoving_average_input.png?alt=media" alt=""><figcaption><p>Compute - Moving average input</p></figcaption></figure>

**Configuration**

```json
{
    "value_col": "sales",
    "column_to_sort": "date",
    "moving_window": 3,
    "group_by": [],
    "new_column_name": "sales_moving_avg"
}
```

**Output**

<figure><img src="https://1809014303-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZxYYf1KpgarKMgMsDCrw%2Fuploads%2Fgit-blob-c1cb3d5914c730ffe786184892b2a4c1cdc812ec%2Fmoving_average_output.png?alt=media" alt=""><figcaption><p>Compute - Moving average output</p></figcaption></figure>
