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

# avg()

**Signature:** `avg(<condition>, "<time_window>")`

**Return Value:** A float representing the average `amount` for matching transactions.

**Description:** Calculates the mean transaction amount for a given filter. Useful for detecting transactions that deviate significantly from a user's typical behavior.

**Example:**

```ws theme={null}
rule UnusualAmountForSource {
    description "Transaction amount significantly exceeds the source's average."

    when avg(when source == $current.source, "P30D") < 500
     and amount > 5000

    then review
         score   0.6
         reason  "Transaction amount far exceeds source's 30-day average"
}
```
