Filter tools in Alteryx allows us to seperate our data based on some relational logic i.e. if we have sales data for a company by region we may wish to look at only sales that occurred in Europe, here we can apply a filter and tell it to seperate the records where Region = Europe. We can apply filters to string, date and numeric data types.
In Alteryx there are two filter tools; one for dates and one for all other data types.
In a filters configuration window we can build a relational expression to define the conditions that will seperate the data. Let’s explore these now.
The filter tool is located in the Preparation section of the tool pallet.
The configuration has two sections Basic Filter and Custom Filter. As the name suggests, the basic filter allows us to quickly build a simple conditional expression to determine what records stay and what records go using one field, a relation operator (equals, not to equal to, greater than etc) and a value (i.e. “Price” greater than 10). The custom filter allows you to build more elaborate expressions that can be as complex as required, containing one or more fields or values as well as sub expressions. You may have noticed that the filter tool has two output nodes labelled “T” and “F”. These stand for true and false, that is any values that evaluate to true based on our condition are output from the “T” node and everything else gets sent from the “F” node. This gives us the option to split our data and process these differently if required.
In our workflow we know that we are trying to get some information about the fiction genre. So let’s filter the product data to seperate the fiction products from the all the others.
Add a filter tool after the cleaning tool to the product data stream.
In the basic filter section of the configuration window; set “Category” to be equal to “Fiction”.
Run the workflow, click on the “T” node of the filter tool and in the results window you should only see “Fiction” records in the category field. Conversly, clicking on the “F” node should show records with anything but “Fiction” in the category field.
The date filter tool (again found in the preparation tab of the tool pallet) works in a similar way to the regular filter tool but is designed with specific features for creating conditional expressions that work with dates.
The date filter allows you to pass one date field and gives you two options for defining which records you would like to allow through to the remaining workflow.
1) We can select a start and end date (i.e.16th April 2018 - 23rd April 2018). All records that have a date within this range in the field we select to filter will be output from the “T” node of the tool.
2) Select either a start date or end data, then select a period (either after or before this) of days, weeks, quarters or years.
In our workflow, we only want data from 2017 for our report. Let’s use a date filter tool to filter out anything that didn’t occur in this year.
In our workflow, we only want data from 2017 for our report. Let’s use a date filter tool to filter out anything that didn’t occur in this year. Our order stream contains an “OrderDate” field which we’ve already converted to a date type so let’s add a date filter after the data cleansing tool in our Orders container.
In the Configuration window for the date filter tool, select the “OrderDate” field and then we are going to use an end date of 1st Jan 2018 with a 1 year preceding period to ensure the filter allows only records with an order date within 2017
After running the workflow you should see only records of orders that occurred within 2017 coming from the “T” output node.