> ## Documentation Index
> Fetch the complete documentation index at: https://upstash-dx-3081-agentkit-tanstack-ai-backends.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# $extendedStats

`$extendedStats` returns `$stats` plus additional distribution metrics.

In addition to `count`, `sum`, `min`, `max`, and `avg`, this operator provides:

* `sumOfSquares`
* `variance`, `variancePopulation`, `varianceSampling`
* `stdDeviation`, `stdDeviationPopulation`, `stdDeviationSampling`
* `stdDeviationBounds` (`upper`, `lower`, plus sampling/population variants)

`sigma` controls the width of `stdDeviationBounds`.

### Compatibility

| Field Type | Supported |
| - | - |
| TEXT | No |
| U64/I64/F64 | Yes |
| DATE | Yes |
| BOOL | No |
| KEYWORD | No |
| FACET | No |

Field must be `FAST`.

### Arguments

| Argument | Type | Required | Description |
| - | - | - | - |
| `field` | `string` | Yes | Field to aggregate. |
| `missing` | `number` | No | Fallback value for missing fields. |
| `sigma` | `number` | No | Multiplier used for standard deviation bounds. |

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    await index.aggregate({
      aggregations: {
        price_extended: {
          $extendedStats: { field: "price", sigma: 2, missing: 0 },
        },
      },
    });
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    index.aggregate(
        aggregations={
            "price_extended": {
                "$extendedStats": {"field": "price", "sigma": 2, "missing": 0}
            }
        }
    )
    ```
  </Tab>

  <Tab title="Redis CLI">
    ```bash theme={null}
    SEARCH.AGGREGATE products '{}' '{"price_extended": {"$extendedStats": {"field": "price", "sigma": 2, "missing": 0}}}'
    ```
  </Tab>
</Tabs>

### Output

Returns a single object containing all basic and extended fields. Example shape:

```json theme={null}
{ "price_extended": {
    "count": 9, "min": 0, "max": 80, "avg": 40, "sum": 360,
    "sumOfSquares": 18000, "variance": 200, "stdDeviation": 14.14,
    "stdDeviationBounds": { "upper": 68.28, "lower": 11.72 }
  }
}
```


## Related topics

- [Overview](/redis/search/aggregation-operators/metric-aggregations/overview.md)
- [Troubleshooting](/redis/search/troubleshooting.md)
- [Aggregations](/redis/search/aggregations.md)
- [$stats](/redis/search/aggregation-operators/metric-aggregations/stats.md)
- [FUNCTION STATS](/redis/commands/functions/function-stats.md)
