# Filter conditions

> Add filter conditions on the trigger or a step.

## Overview

When you’re setting up an automation, you can use filter conditions to refine how the automation behaves. For example:

-   In triggers, add filter conditions to narrow down when the automation will run. For example, add a condition so the automation only triggers for people located in Chicago.
-   When adding a step to query data, add filter conditions to refine the results of the query. For example, add a condition to a query of employee data so that it only returns people with an EEOC classification of _Executive_.
-   When adding branching logic, add filter conditions that determine which path the automation will go down. For example, add a condition so that the automation follows one path for employees in the US and another path for employees in Australia.

* * *

## Attributes you can use in a filter condition

You can create filter conditions using data from the trigger object and the preceding steps of the automation. For example:

-   If the trigger event is _Hiring request is submitted_, you can add filter conditions using fields from the _Employee_ object.
-   If the trigger event is a record change to a custom object, you can add filter conditions from any of the fields in that custom object and any of the attributes in objects where a lookup relationship exists.

When you add a filter condition, you add details that determine the behavior of the filter. Depending on the field you select, this will include the specific amounts, timeframes, or values to use in the filter.

When you use an attribute that is a number or percentage, you can enter either a positive or negative number.

> **Note:**
> Your permissions determine which specific fields are available to use. For more information, see [Automation permissions](https://developer.rippling.com/documentation/rippling-platform/developer/workflows/permissions).

* * *

## Add conditions that trigger based on a record change

When you trigger an automation based on an update to a record, you can narrow down the trigger by adding conditions related to the change event. To do this, select a field and then add the logic you want to use. You can select from the following operators:

-   **After the change** - Trigger only for records where the value of the field after the triggering event is what you specify.
-   **Before the change** - Trigger only for records where the value of the field before the triggering event is what you specify.
-   **Changes** - Trigger for records where the field you select is changed in any way.
-   **Changes to** - Trigger only for records where the value of the field you select changes to a value you specify.

When you use **Changes** or **Changes to**, the condition applies _only when the field you selected changes_.

When you use **After the change** or **Before the change**, the condition applies _regardless of which field changed_.

For example, say you create the following automation:

-   Trigger event: When something happens > Other > Employee is updated
-   Filter condition: Hourly rate after the change is equal to $27.00

| **Scenario:** | Someone’s hourly rate is updated |
| --- | --- |
| **Result:** | If the person's new hourly rate is $27.00, the automation will trigger. If the person's new hourly rate is $30.00, the automation will not trigger |

| **Scenario:** | Someone’s title is updated. Their hourly rate is NOT updated |
| --- | --- |
| **Result:** | If the person's hourly rate is $27.00, the automation will trigger. If the person's hourly rate is $30.00, the automation will not trigger |

| **Scenario:** | Someone’s department and hourly rate are both updated in the same profile change |
| --- | --- |
| **Result:** | If the person's new hourly rate is $27.00, the automation will trigger. If the person's new hourly rate is $30.00, the automation will not trigger |

* * *

## Use fields in filter conditions

You can also include fields in filter conditions. This can be particularly useful for comparing values. For example, to filter a trigger event so that it only fires if the person’s annual compensation is greater than the midpoint of their compensation band, you would do the following:

1.  Select _Annual compensation_.
2.  Select _Is greater than_.
3.  Select the **Field** tab, then select the _Annual Base Compensation Band Mid_ field.

* * *

## Aggregations

When you add filter conditions to a automation trigger, you have the option to select from aggregations.

Aggregations represent data in Rippling where there is a one-to-many relationship. For example, a single person may have many documents, pay runs, time off requests, devices, or GitHub pull requests.

### Add a condition based on the count of items

Add a condition that uses the total count of items. For example:

-   Filter to employees that have no approved leave request in the last 6 months.
-   Filter to employees that have more than 3 devices.

To do this, select the **Count of…** option in the condition builder, then add your criteria.

### Add a condition based on an item’s attributes

Add a condition based on the attributes of an item. For example, filter to employees where any of their devices is marked as stolen.

To do this, navigate to the **Other aggregations** section and select the desired criteria.

### Select an item based on its rank in the list

When you select a numeric, text string, or date field in an aggregation, you can select an item based on its relative position in the list, such as the most recent or the least recent date. You’ll sort the list in descending or ascending order and then specify the position or rank.

For example, to select the second most recent device assignment, select **descending** order and then enter **2** as the rank.

### Specify pre filter or post filter

You can indicate when in the data processing sequence the filter should be applied using the pre filter and post filter options.

> **Note:**
> This is an advanced option. When in doubt, leave this set to **pre filter**, which covers the most common scenarios.

-   **Pre filter** first applies the filter condition, then extracts the item you specify.
-   **Post filter** first extracts the item you specify, then applies the filter condition.

For example, say you are adding a filter condition where the _most recent leave start date is before 30 days ago_.

|  | **Pre filter** | **Post filter** |
| --- | --- | --- |
| **Logic used** | 1\. Filter all leave requests to only those with end dates more than 30 days ago. 2. From this filtered set, select the most recent leave end date | 1\. Find the most recent leave end date (regardless of when it occurred). 2. Check if that specific date is more than 30 days ago |
| **Result** | The most recent leave end date among leaves that ended more than 30 days ago is selected | The automation returns a true/false response for whether the employee's most recent leave ended more than 30 days ago |
| **Useful for** | Finding people who took extended leave in the past but haven't taken any recent leave | Finding people who haven't taken any leave recently, regardless of previous patterns |

* * *

## See also

-   [Get started with automations](https://developer.rippling.com/documentation/rippling-platform/developer/workflows/get-started)
-   [Automation permissions](https://developer.rippling.com/documentation/rippling-platform/developer/workflows/permissions)
-   [Automation triggers](https://developer.rippling.com/documentation/rippling-platform/developer/workflows/triggers)
-   [Automation variables](https://developer.rippling.com/documentation/rippling-platform/developer/workflows/variables)
-   [Automation steps](https://developer.rippling.com/documentation/rippling-platform/developer/workflows/steps)
-   [Automation troubleshooting](https://developer.rippling.com/documentation/rippling-platform/developer/workflows/troubleshooting)

Source: https://developer.rippling.com/documentation/rippling-platform/developer/workflows/filter-conditions

> For the complete documentation index, see [llms.txt](https://developer.rippling.com/llms.txt). Public pages have a Markdown version at the same URL with .md added.
