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

# Table Filter

> A filter component for tables with multiple condition support

<img src="https://mintcdn.com/evidence/3VqmJP-3dtFa-PrP/images/components/table_filter/table_filter.png?fit=max&auto=format&n=3VqmJP-3dtFa-PrP&q=85&s=bcf23945899bee094b96181b1d1e0992" alt="Using filters" width="1000" height="112" data-path="images/components/table_filter/table_filter.png" />

```liquid theme={null}
{% table_filter
    id="my_filter"
    data="demo.daily_orders"
/%}

{% bar_chart
    data="demo.daily_orders"
    x="date"
    y="sum(total_sales)"
    filters=["my_filter"]
    date_grain="month"
/%}
```

## Examples

### Using `filters`

<img src="https://mintcdn.com/evidence/3VqmJP-3dtFa-PrP/images/components/table_filter/table_filter.png?fit=max&auto=format&n=3VqmJP-3dtFa-PrP&q=85&s=bcf23945899bee094b96181b1d1e0992" alt="Using filters" width="1000" height="112" data-path="images/components/table_filter/table_filter.png" />

```liquid theme={null}
{% table_filter
    id="my_filter"
    data="demo.daily_orders"
/%}

{% bar_chart
    data="demo.daily_orders"
    x="date"
    y="sum(total_sales)"
    filters=["my_filter"]
    date_grain="month"
/%}
```

### Using Inline SQL

````liquid theme={null}
{% table_filter
    id="my_filter"
    data="demo.daily_orders"
/%}

```sql filtered_orders
select * from demo.daily_orders
where {{my_filter.filter}}
```

{% table data="filtered_orders" /%}
````

### Custom Title

```liquid theme={null}
{% table_filter
    id="orders_filter"
    data="demo.daily_orders"
    title="Order Search"
/%}
```

### Mixed Single and Multi Select

```liquid theme={null}
{% table_filter
    id="mixed_filter"
    data="demo.daily_orders"
    columns=["category", "item"]
    single_select=["category"]
/%}
```

## Attributes

<ResponseField name="id" type="string" required>
  Unique identifier for the filter component
</ResponseField>

<ResponseField name="className" type="string">
  Additional CSS classes to apply
</ResponseField>

<ResponseField name="data" type="string" required>
  ID of the table to filter
</ResponseField>

<ResponseField name="title" type="string" default="Filter">
  Custom title text for the filter button (defaults to "Filter")
</ResponseField>

<ResponseField name="defaultConjunction" type="string" default="AND">
  Default conjunction between filters (AND or OR)

  **Allowed values:**

  * `AND`
  * `OR`
</ResponseField>

<ResponseField name="columns" type="array">
  Array of column IDs to filter on. If not provided, all columns are available for filtering
</ResponseField>

<ResponseField name="labels" type="array">
  Array of custom labels to display instead of column names. Must match the order of the columns array.
</ResponseField>

<ResponseField name="showClearButton" type="boolean" default="true">
  Whether to show a clear button to remove all filters
</ResponseField>

<ResponseField name="minimumRecords" type="number">
  When set, string filters will only show values that have at least this many records, and filters will always use AND conjunction
</ResponseField>

<ResponseField name="multiple" type="boolean" default="true">
  When false, string filters will only allow selecting a single value instead of multiple values. Can be overridden per column with single\_select and multi\_select.
</ResponseField>

<ResponseField name="single_select" type="array">
  Array of column names whose string filter only allows selecting a single value, regardless of the multiple setting
</ResponseField>

<ResponseField name="multi_select" type="array">
  Array of column names whose string filter allows selecting multiple values, regardless of the multiple setting
</ResponseField>

<ResponseField name="initial_values" type="object">
  An object with column names as keys and this filter's initial value for that column as the value
</ResponseField>

<ResponseField name="require_selection" type="array">
  An array containing column names that always require a selection. Only supports text columns.
</ResponseField>

<ResponseField name="width" type="number">
  Set the width of this component (in percent) relative to the page width
</ResponseField>

## Using the Filter Variable

Reference this filter using `{{filter_id}}`. The value returned depends on where you use it.

| Context           | Default Property | No Selection | Result                                            |
| ----------------- | ---------------- | ------------ | ------------------------------------------------- |
| Inline SQL query  | `.filter`        | `true`       | `category = 'Electronics' AND total_sales > 1000` |
| `where` attribute | `.filter`        | `true`       | `category = 'Electronics' AND total_sales > 1000` |
| Text / Markdown   | `.filter`        | `true`       | `category = 'Electronics' AND total_sales > 1000` |

### Available Properties

You can also access specific properties using `{{filter_id.property}}`:

#### .filter

Returns a complete SQL filter expression combining all active filter conditions. Returns `true` when no filters are active.

````liquid theme={null}
{% table_filter id="my_filter" data="demo.daily_orders" /%}

```sql filtered_orders
select * from demo.daily_orders
where {{my_filter}}
```
````

**Example value:** `category = 'Electronics' AND total_sales > 1000`
