> For the complete documentation index, see [llms.txt](https://1spatial.gitbook.io/fme-form-beginner/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://1spatial.gitbook.io/fme-form-beginner/transformer-usage/conditional-filtering/transformers-that-filter.md).

# Transformers that Filter

Many transformers in the Filters and Joins category carry out these tests and redirect data according to the results:

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

Although the Tester transformer is the most used of this category, there are many other transformers such as the TestFilter, GeometryFilter, AttributeFilter, SpatialFilter, and Sampler.

## The Tester and TestFilter Transformers

The Tester and TestFilter are the two key transformers for conditional filtering. They test the values on attribute values.

### Tester

The Tester transformer is generally for single tests that produce a Yes/No result.

For example, here we wish to decide whether to send out snow ploughs to a particular road based on whether the value of the Snowfall attribute is greater than 150 mm (approximately 6 inches):

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

If snowfall is greater than 150, the road feature will pass the test and snow ploughs will be sent.

#### Multiple Clauses

Each clause in the Tester is an individual test that allows a Passed/Failed result. For example, each of the following criteria might be separate tests:

* Has there been more than 100 mm (4 inches) of snowfall?
* Is this a major road?
* Is the temperature less than zero degrees Celsius?
* Was sand last applied more than 24 hours ago?

However, the Tester allows the combination of multiple tests, where a user can combine any number of clauses using an AND and OR statement. So instead of individual tests, I might ask:

* Is this an Arterial (major) road AND has there been more than 100 mm of snow?

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

The Tester also allows the mixing of AND and OR statements using what is called a Composite Test. For example:

* Is this an Arterial road AND (has there been more than 100 mm of snow OR (is the temperature less than zero AND was the road treated (with sand) more than 24 hours ago))?

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

But - however complex the test becomes - it still results in a single Yes/No (binary) result; features will either pass or fail this set of tests.

It's also worth remembering that we aren't restricted to simple tests of equality (A=B); in the above, there are also "greater than" and "less than" tests. That's because there are many different operators available for use in a test clause.

#### The Operators

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

Besides the usual operators, there are also some based on a SQL where clause. These include:

* In
* Like
* Contains
* Begins With
* Ends With
* Contains Regex

...plus there are other tests that check for the existence of attributes and values: Attribute has a value

* Attribute has a value
* Attribute is Null
* Attribute is Empty String
* Attribute is Missing

{% hint style="info" %}
**TIP**

*"Attribute has a value" is the opposite of the three other tests; for example, this attribute is not Null, AND it is not an empty string, AND it is not missing. Incidentally, "missing" means the attribute does not exist at all on the feature being tested.*
{% endhint %}

### TestFilter

The TestFilter allows a number of conditions to be tested, each of which can have a number of test clauses. Each condition is given an output port, with an additional output port for features that fail all of the test conditions.

The TestFilter is very similar to the CASE or SWITCH command in programming or scripting languages. In Workbench it looks like this:

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

Notice that there are multiple conditions, and an output port for each. Each condition/port combination is equivalent to a single Tester transformer; hence the TestFilter is a good way to combine multiple Tester transformers into one.

The TestFilter output ports can be given custom names, rather than a simple PASSED/FAILED, which is another advantage to this transformer over the Tester.

The TestFilter has the full set of operators available with the Tester such as equals, greater than, less than, and so forth. Each condition is tested in turn.

Features that pass are output through the matching output port. Features that fail are sent on to the next condition in the list. Therefore it’s very important to get the conditions in the correct order.

{% hint style="info" %}
**NOTE**

*The TestFilter is very good for filtering a feature by a set of cascading conditions, for example here are a set of tests to again determine whether to send out a snow plow:*

* *Has there been more than 150 mm of snowfall?*
* *Has there been more than 100 mm of snowfall AND is this an Arterial road?*
* *Is the temperature less than zero degrees Celsius AND was sand last applied more than 24 hours ago?*

*It’s a set of cascading tests because if there has been more than 150 mm of snow, the plows are sent out anyway; you don’t need to test any other criteria. So the test order can be very important. If every test is a fail, then the plows are not sent out.*
{% endhint %}

If using the above snowfall example, you were using three Tester transformers, you could save space on the workspace canvas and replace that setup with just a single TestFilter.

{% hint style="info" %}
**NOTE**

*Because the TestFilter can carry out a single test (as well as multiple ones) it's possible to use it exclusively instead of the Tester transformer.*
{% endhint %}


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://1spatial.gitbook.io/fme-form-beginner/transformer-usage/conditional-filtering/transformers-that-filter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
