Filter Tool
One Tool Example
Filter has a One Tool Example. Visit Sample Workflows to learn how to access this and many other examples directly in Alteryx Designer.
Use Filter to select data using a condition. Rows of data that meet the condition are output to the True anchor. Rows of data that do not meet the condition are output to the False anchor.
The Filter tool can...
Select rows by comparing a column against a static value. See an example.
Select rows with or without missing data. See an example.
Select rows using date-time data. See an example.
Select rows using a multiple-column condition. See an example.
Select rows using a compound condition. See an example.
Tool Components
![Screenshot of the filter tool on the Designer canvas](../../../image/uuid-707d5917-a4eb-8d79-61aa-02f0c79da026.png)
The Filter tool has 3* anchors
Input anchor: Use the input anchor to select the data you want to filter.
T (True) anchor: The True anchor outputs the rows of data that meet the filter condition.
F (False) anchor: The False anchor outputs the rows of data that do not meet the filter condition.
*Because the Filter tool includes an expression editor, an additional input anchor displays when you use Filter in an app or macro. Use the Interface tools to connect to a Question anchor.
Configure the Tool
Select Basic filter or Custom filter.
Use the Basic filter to build a simple query on a single column of data.
Use the Custom filter to build complex conditions or conditions using more than one column.
![Screenshot of Filter configuration window with options to select Basic filter or Custom filter.](../../../image/uuid-c281e041-43ec-2cc9-4e3c-dcc64754572c.png)
Build a Basic Filter
Select the column of data to filter by in the Select column dropdown.
Select the operator in the next dropdown. Available operators depend on the data type of the column you selected to filter by. See Basic Filter Operators below.
Enter a value to complete the condition.
Basic Filter Operators
Available operators depend on the data type of the column you select to filter by. Learn more about Data Types.
Operator | Description | Available Data Types |
---|---|---|
= | Value matches input. | Numeric, Date, DateTime |
Equals | Value matches input. | String |
!= | Value does not match input. | Numeric, Date, DateTime |
Does not equal | Value does not match input. | String |
> | Value is greater than input. | Numeric, Date, DateTime |
>= | Value is greater than or equal to input. | Numeric, Date, DateTime |
< | Value is less than input. | Numeric, Date, DateTime |
<= | Value is less than or equal to input. | Numeric, Date, DateTime |
Is null | Value is a missing or unknown value. | Numeric, Date, DateTime, Time, String, Spatial, Boolean |
Is not null | Value is not a missing or unknown value. | Numeric, Date, DateTime, Time, String, Spatial, Boolean |
Comes before (<) | Value sorts to come before input. | String |
Comes after (>) | Value sorts to come after input. | String |
Contains | Value is found in any part of the string. | String |
Does not contain | Value is not found in any part of the string (case sensitive). | String |
Is empty | Value is Null or "". | String |
Is not empty | Value is not Null or "". | String |
Range | Value is a selected start and end date. | Date, DateTime |
Start date and periods after | Value is the selected first date and a set number of periods that follow. | Date, DateTime |
End date and periods before | Value is the selected last date and a set number of periods that precede. | Date, DateTime |
Is true | Value is true. | Boolean |
Is false | Value is not true. | Boolean |
Build a Custom Filter Using Expressions
To build a custom filter condition, enter your expression syntax into the expression editor. There are also many tools to assist with building Custom filter conditions. See Expression Editor Tips.
![Screenshot of a Custom filter setup](../../../image/uuid-d525f506-2dcb-17f5-1234-f0163c40fa38.png)
Expression Editor Tips
These tools are available within the expression editor to assist with building Custom filter conditions.
Press Ctrl + Space to view a list of all functions.
Type a word or phrase to view a matching list of functions.
Type a [ (left bracket) to view a list of variables to use in the expressions. Variables can be...
Data from an incoming connection or a column created in a previous expression.
Values from an Interface tool connected to the Question anchor of a tool with an expression editor when the tool is used in an app or macro. Use the Question anchor when you want to use question values as variables in the expression. See Interface Tools.
Global variables that are defined in workflow configuration. See Constants.
Select the fx icon to search and browse functions. See Functions.
Select the x icon to browse or search columns and constants.
Select the folder icon to browse or search recent and saved expressions.
Save a Custom Filter
Once you have built an expression you can save it for later use. Select the save icon. Enter your expression name and select Save.
Tool Examples
Example 1. Select Rows Using a Basic Comparison
Use the Basic filter to select rows by comparing a column against a static value.
![Screenshot of a Basic filter setup](../../../image/uuid-aac7ff4d-8109-868f-cfe4-9735c5c63207.png)
According to the condition of the above Basic filter, rows with a CustomerID value greater than 30 are output to the True anchor.
![Screenshot of the True anchor results which includes all rows where CustomerID is greater than 30](../../../image/uuid-6dd3e912-6867-aaa8-7d73-2ce6bfb1e30e.png)
Rows with a CustomerID value that is not greater than 30 are output to the False anchor.
![Screenshot of the False anchor results which includes all rows where CustomerID is not greater than 30](../../../image/uuid-d5e3f2aa-1145-cc2d-b26b-97215797b9b3.png)
Example 2. Select Rows With or Without Missing Data
Use the Basic filter to select rows without missing data.
![Use the Basic filter to select records without missing data.](../../../image/uuid-f58e2a02-3e88-f969-618e-6e6ea943148c.png)
According to the condition of the above Basic filter, rows with a LastName value that is not null (missing) are output to the True anchor.
![Rows with a LastName that is not null (missing) are output to the True anchor.](../../../image/uuid-b014be4b-6136-091b-cb84-b5bb721ca4bc.png)
Rows with a null value in LastName are output to the False anchor.
![Screenshot of the False anchor results which shows all rows with a null value in LastName](../../../image/uuid-1df222f5-7926-0445-1779-fbda1fd6438e.png)
Example 3. Select Rows Using Date-Time Data
Use the Basic filter to select rows with a relative date.
![Screenshot of a Basic filter with the condition JoinDate is less than or equal to todaye.](../../../image/uuid-f5be1b0d-9f4c-9d9b-8831-9b37b1343c26.png)
According to the condition of the above Basic filter, rows with a JoinDate that is less than or equal to today's date are output to the True anchor.
![Screenshot of True anchor results which shows rows with a JoinDate that is less than or equal to today's date](../../../image/uuid-cb92d6f9-99f9-c211-cba4-c9b53e1eb4e7.png)
Rows with a date after today's date are output to the False anchor.
![Screenshot of False anchor results which shows rows with a JoinDate after today's date](../../../image/uuid-084d5786-40dc-c7d5-ff49-be0288c025f2.png)
Date-Time Filter Tips
The dynamic options, today, tomorrow, and yesterday, update the workflow to that relative date when the workflow is run.
The Start date and periods after or End date and periods before operators allow you to specify a date range by selecting a specific date, a Period type (Days, Months, Weeks, Quarters, or Years), and the Number of periods before or after.
Select Filter only Date data to truncate date-time data to use only the date data.
Example 4. Select Rows Using a Multiple-Column Condition
Use the Custom filter to create a condition that references more than one column to select rows.
![Screenshot of a custom filter with the condition JoinDate is greater than or equal to the FirstPurchaseDate](../../../image/uuid-e2c59cd2-3d8c-6c38-5f7b-377112ae5cc3.png)
According to the condition of the above Custom filter, rows with a JoinDate that is greater than or equal to the FirstPurchaseDate are output to the True anchor.
![Screenshot of the True anchor results which shows rows with a JoinDate that is greater than or equal to the FirstPurchaseDate](../../../image/uuid-a1f17ff4-09ad-40fa-60ce-ad3b4ee8ab22.png)
Rows with a JoinDate that is less than the FirstPurchaseDate are output to the False anchor. In this case, there are no rows that have a JoinDate less than the FirstPurchaseDate.
Example 5. Select Rows Using a Compound Condition
Use the Custom filter to create compound conditions, that is, more than one condition joined by and/or operators.
![Screenshot of a Custom filter with the condition where the region is either South or contains the word West](../../../image/uuid-7e7a9c7c-7718-b0cc-5aa6-594adf629ec3.png)
According to the condition of the above Custom filter, rows where the region is either South or contains the word West, are output to the True anchor.
![Screenshot of the True anchor results which shows rows where the region is either South or contains the word West](../../../image/uuid-27775085-d906-13a7-9d64-649b0758dad3.png)
All other rows are output to the False anchor.
![Screenshot of the False anchor results which shows all rows where region is not South and does not contain the word West](../../../image/uuid-1dc5d917-625c-a101-54e6-8f16a82facde.png)
Troubleshooting
Treat numbers with more than 15 digits as strings to prevent loss of precision. You can set the field type to a string using the Select Tool.