> For the complete documentation index, see [llms.txt](https://docs.getmesa.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.getmesa.com/tools/filter.md).

# Filter

The **Filter** tool is a step that lets you stop your workflow based on the conditions you set. A Filter is different than a [Path](https://docs.getmesa.com/tools/paths) because it controls whether or not your workflow continues. A Path continues the workflow for a different outcome based on the conditions set.

You should use a Filter in your workflow when there are certain reasons why you would want your workflow to stop or continue or to only act on specific items or instances.

## Configure

When using the Filter tool, you will need to select the correct [variables](/workflow-builder/fields/variables.md) so that MESA can apply the filtering based on the data returned by the previous steps of your workflow.

<figure><img src="/files/c4MgWfxwJjOGluoMsuWk" alt=""><figcaption></figcaption></figure>

## Examples of Conditions <a href="#examples" id="examples"></a>

The Filter tool has nineteen conditions you can use to compare values.

<table data-full-width="true"><thead><tr><th>Condition</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td>Equals</td><td>A specified field matches an exact value provided</td><td>The number of line items in an order is equal to 2</td></tr><tr><td>Does not equal</td><td>A specified field does not match an exact value provided</td><td>The number of line items in an order is not equal to 2</td></tr><tr><td>Contains</td><td>A specified field includes a certain value within its content, regardless of its position in the text</td><td>An order's tags contains a "VIP" tag</td></tr><tr><td>Does not contain</td><td>A specified field does not include a certain value within its content, regardless of its position in the text</td><td>An order's tags does not contain a "VIP" tag</td></tr><tr><td>Is empty </td><td>A specified field has no data, meaning it is blank or null</td><td>An order's tags are empty</td></tr><tr><td>Is not empty</td><td>A specified field has data, meaning it is not blank or null</td><td>An order's tags are not empty</td></tr><tr><td>Is greater than</td><td>A specified field is numerically higher than a given value</td><td>A customer's order count is more than 2</td></tr><tr><td>Is less than </td><td>A specified field is numerically lower than a given value</td><td>A customer's order count is less than 2</td></tr><tr><td>Is less than or equal to</td><td>A specified field is numerically lower than or exactly equal to a given value</td><td>A customer's order count is less than or equal to 2</td></tr><tr><td>Is greater than or equal to</td><td>A specified field is numerically higher than or exactly equal to a given value</td><td>A customer's order count is greater than or equal to 2</td></tr><tr><td>Is in</td><td>A specified field matches any one of the values within a defined list or content</td><td>US is in a customer's country code address</td></tr><tr><td>Is not in</td><td>A specified field does not match any one of the values within a defined list or content</td><td>US is not in a customer's country code address</td></tr><tr><td>Starts with</td><td>A specified field value starts with a specific, or sequential, numbers or characters</td><td>A product's SKU starts with 123</td></tr><tr><td>Does not start with</td><td>A specified field value does not start with a specific, or sequential, numbers or characters</td><td>A product's SKU does not start with 123</td></tr><tr><td>Ends with</td><td>A specified field value ends with a specific, or sequential, numbers or characters</td><td>A product's SKU ends with XYZ</td></tr><tr><td>Does not end with</td><td>A specified field value does not end with a specific, or sequential, numbers or characters</td><td>A product's SKU does not end with XYZ</td></tr><tr><td>Is after [date/time]</td><td>A specified date/time value falls later than a given date or time</td><td>An order was created after 10/24/24 12:00AM</td></tr><tr><td>Is before [date/time]</td><td>A specified date/time value is earlier than a given date or time</td><td>An order was created before 10/24/24 12:00AM</td></tr><tr><td>Is on [date]</td><td>A specified date value matches exactly with a given date</td><td>An order was created on 10/24/24</td></tr></tbody></table>

When using dates or time frames as a condition or rule within the Filter step, you have the ability to use [specific date formats](https://docs.getmesa.com/workflow-builder/fields/liquid-templating#date).&#x20;

{% hint style="info" %}
Please note that values will be case-sensitive
{% endhint %}

## Going Further <a href="#multiple" id="multiple"></a>

### Multiple rule sets <a href="#multiple" id="multiple"></a>

You can apply additional rules by clicking the **More fields** button, then selecting the Additional Rules checkbox.

<figure><img src="/files/nOHR8uUwsakJv0PlFF5R" alt=""><figcaption></figcaption></figure>

Define if all rules need to match (`AND`), or if only one of your rules needs to match (`OR`). You can add an unlimited number of rule sets by clicking the Add Rule button to build complex comparison logic.

<figure><img src="/files/48tomLtTvC8bgmbfaV8d" alt=""><figcaption></figcaption></figure>

## Technical Notes

### Advanced rule sets <a href="#advanced" id="advanced"></a>

If you use a combination of **AND** or **OR** operators, the logic will read from top to bottom. For example, `a AND b OR c AND d` will be executed as `((a && b) || c) && d`.&#x20;

#### **AND Filter will only** proceed if *both* conditions are true.

* **Example**: Order created is more than $5 **AND** it is the customer's first order.&#x20;
* **Action**: If both conditions are met, the task continues. Otherwise, it stops.

**OR Filter will proceed if at least&#x20;*****one*****&#x20;of the listed conditions is true**

* **Example**: Order created is more than $5 **OR** it is the customer's first order.&#x20;
* **Action**: If one condition is met, the task continues. Otherwise, it stops.

For more fine-grained control, separate your **AND** comparisons and **OR** comparisons into separate Filter steps.

<figure><img src="/files/5y4FI0XWAzd3ZoH1UnZz" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/jYk6GNUxcYhBbnUBtHDy" alt=""><figcaption></figcaption></figure>

### Special values

The following values will be automatically cast from strings to their respective types:

* `true`
* `false`
* `null`

### Creating a custom comparison

You can further adjust the functionality of a Filter step by opening the step options (three vertical-dot icon) and clicking Edit code.

<figure><img src="/files/JSWJJl2aJb0YPhW1FkGf" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/hI6jsaDohumbr63Wl9N2" alt=""><figcaption></figcaption></figure>
