> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elementary-data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# anomaly_direction

> [card] [Generate your anomaly test with Elementary AI](https://elementary-data.com/community)
>
> Let our Slack chatbot create the anomaly test you need.

`anomaly_direction: both | spike | drop`

By default, data points are compared to the expected range and check if these are below or above it.
For some data monitors, you might only want to flag anomalies if they are above the range and not under it, and vice versa.
For example - when monitoring for freshness, we only want to detect data delays and not data that is “early”.
The anomaly\_direction configuration is used to configure the direction of the expected range, and can be set to both, spike or drop.

> [!NOTE]
>
> This setting does not change how the expected range is calculated. The average and standard deviation are taken over every bucket in the training period, whichever direction you choose, and `anomaly_direction` only decides which side of the range raises an alert.
>
> So `drop` does not mean "the standard deviation of drops only". A table that has never dropped still varies from bucket to bucket, and that variation is what a real drop gets measured against.

* *Default: `both`*
* *Supported values: `both`, `spike`, `drop`*
* *Relevant tests: All anomaly detection tests*

![anomaly\_direction change impact](https://res.cloudinary.com/diuctyblm/image/upload/v1681301375/Anomaly%20detection%20tests/anomaly_direction_r1sdl9.png)

anomaly\_direction change impact

```yml test theme={null}
models:
  - name: this_is_a_model
    data_tests:
      - elementary.volume_anomalies:
          arguments:
            anomaly_direction: drop

      - elementary.all_columns_anomalies:
          arguments:
            column_anomalies:
              - null_count
              - missing_count
              - zero_count
            anomaly_direction: spike
```

```yml model theme={null}
models:
  - name: this_is_a_model
    config:
      elementary:
        anomaly_direction: drop
```

```yml dbt_project theme={null}
vars:
  anomaly_direction: both
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.