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

# Filter

# \$filter

The `$filter` operator filters elements from an array based on a provided condition.

## Input

* An array containing an array to filter and a condition to evaluate for each element

## Output

* A new array containing only the elements that satisfy the condition

## Examples

### Filter Even Numbers

```json theme={null}
{
  "$filter": [
    [1, 2, 3, 4, 5, 6],
    {
      "$eq": [
        {
          "$mod": [
            {
              "$var": ["current"]
            },
            2
          ]
        },
        0
      ]
    }
  ]
}
```

Result: `[2, 4, 6]`

### Filter From Field

```json theme={null}
{
  "$filter": [
    {
      "$input": "products"
    },
    {
      "$gt": [
        {
          "$var": ["current"]
        },
        100
      ]
    }
  ]
}
```

Result: An array of products with values greater than 100
