> For the complete documentation index, see [llms.txt](https://docs.appfarm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appfarm.io/reference/platform-concepts/filters.md).

# Filters

Filters are used with data sources to create a subset of data. You can set a filter directly on a data source when it's created, or apply a filter to a data source in the UI or actions. Filters are continuously evaluated, so objects can be dynamically added and removed while an app is in use.

## Usage

Filters are [configured in the same way as conditions](/reference/platform-concepts/conditions.md#condition-editor), and rely on the same [operators](/reference/platform-concepts/operators.md), but always return a data source with 0 or more objects. Filters can be applied in the following cases:

### App data sources

When you add an object class as a data source to an app, you should usually add a filter. The filter determines which data should be read from the database into the data source. See [server-side vs. client-side filters](#server-side-vs.-client-side-filters) for more information on why filters are important on data sources.

A data source filter has no object in context. When the filter compares with a value from a data source with cardinality many, the value is read from that data source's single selected object (**Single Selected**). In UI, action and function filters the option is **Context / Single Selected**: the object in context, or the single selected object when there is none.

### Iterating UI components

Filters can be applied to iterating [containers](/library/ui-components/container.md), Select, [Multi Select](/library/ui-components/multi-select.md), [Radio buttons](/library/ui-components/radio-buttons.md), [Table](/library/ui-components/table.md), Data Grid, [List](/library/ui-components/list.md), Chip group, Avatar group, Map layers, and [Chart](/library/ui-components.md#basic-charts) components, including Gantt and gauge charts. In this case the filter acts as an additional filter to the one applied directly to the data source. This is referred to as *UI filtering* and applies only in the context of that single UI component.

You can also add conditional filters, which are enabled when a specific [condition](/reference/platform-concepts/conditions.md) is true. These are often used to provide users with filters they can apply dynamically while they use the app.

### Action nodes

In the [For each action node](/library/action-nodes/foreach.md), which loops through the objects in a data source, you can apply a filter to the data source. Only the objects that match the filter will be iterated.

In the [Read objects](/library/action-nodes/read-objects.md), [Update object](/library/action-nodes/update-object.md), and [Delete objects](/library/action-nodes/delete-objects.md) action nodes, you can specify that the **Selection** is a `Filtered selection` and add a filter. The action will then only affect the objects that match the filter.

### Functions

In the function editor, when you add a multi-cardinality data source as a function parameter, you can specify that the **Selection** is a `Filtered selection` and add a filter. The parameter will only contain the objects that match the filter.

### Conditions

When you create an expression in the [condition editor](/reference/platform-concepts/conditions.md#condition-editor) that uses the *Exists in* or *Not exist in* operators, you can define a filtered selection from a data source as the right operand.

## Server-side vs. client-side filters

In general, filters can be applied both server-side and client-side.

A filter applied using the **Filter** property on database connected data sources in apps is a server-side filter. The filter is applied on the server, and only the objects which meet the criteria of the filter are sent to the app.

Server-side filters reduce how much data is sent to the app, which helps performance. They are not a security boundary: filter inputs come from the app, and the same user can query the data in other ways. Use object class permissions to decide who may see what (see [Designing secure permissions](/reference/security/permissions/designing-secure-permissions.md)).

All other filters, such as those applied in the UI or in actions, are client-side filters. This includes filters added using the [**Client Filters**](/reference/apps/data/data-sources.md#client-filters) property on database connected data sources.

For example, say you have a database connected data source *Orders*, that contains all orders from the last 3 months. You then apply a filter with the expression `Order.Responsible EQUALS Current User` in a table in a view called *My Orders*. This filter will be applied at the moment the view has evaluated that the table should be displayed in your app, and is run in the browser.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appfarm.io/reference/platform-concepts/filters.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
