Filter Operator
Overview
The Filter operator allows you to filter your data based on given criteria. First, you'll give the Filter operator a formula. Then, the operator finds all matching data in your data set. This helps you avoid selecting an entire rows or columns of data that don't fit your needs.
For example, you ask your end-user if they smoke. Your end-user can answer Yes or No, and you only want to see the Yes responses. The Filter operator makes this easy.
You'll notice the Filter operator has 2 output ports. One outputs the data matching your criteria. The other outputs data that doesn't match. You can make use of 1 or both of these outputs.
You can also connect an Input to the argument port of a Filter operator. This lets you sort based on a dynamic variable. For example, you could have a list of products in a Data Table. The list of available products may depend on whether your client smokes or not. So, you can add a Dropdown component that offers Yes or No responses. With the Dropdown set as an argument, the operator filters based on the selection.
You’ll find the Filter operator under the Table Group to the left of your canvas.
What You'll Learn
In this article, you'll learn:
Info Window Settings
Here's what the operator looks like, along with its Info window:
And here's a breakdown of each setting in the Info window:
Setting |
Description |
---|---|
Label |
Sets the label for your operator. The label you enter here shows beneath your operator on your Data Workflow canvas. This field is optional, but set a label if you use more than one of the same operator type. A label helps you identify your operators without opening any Info windows. |
Do Not Sanitize Formula |
When unchecked, the operator will do its best to clean up special characters in your formula. Those special characters include ', $, #, &. In other words, the operator will sanitize your formula. Sanitizing can improve performance. But, when using a complex formula, it can also lead to unexpected data behavior. When checked, the operator uses your formula as-is. This is your safest bet when working with a complex formula. By default, this setting is unchecked, which means the operator will try to sanitize your formula. |
Expression |
Here, you'll enter the criteria you want to filter your data by. The expression can be a single number, a string, an argument, or a full formula. For example, to find Yes data for the Do you smoke? expression, you'd use this formula: doYouSmoke="Yes". Matched data goes through the upper output port. Unmatched data goes through the lower output port. You can also add conditions to a formula. Conditioning your Expression filters your data using AND or OR. AND returns data that's true for all criteria listed. OR checks if any one of the conditions you list is true. Let's look at an example. Say you're pulling data for citizenship from different countries. You want to identify citizens from the United States of America and Mexico. By using AND, you'll only include those who have citizenship in all of the countries you list. To only accept dual citizens as an Input, use this formula: =AND(citizen=‘Mexico’, citizen=‘USA’). By using OR, you'll filter citizens from either country you list. To include citizens from either country as an Input, use this formula: =OR(citizen=‘Mexico’, citizen=‘USA’). |
Adding a Filter Operator
To see a Filter operator in action, let's look at an example. You'll create a Data Table that holds a list of countries. In the Data Table, you'll include a column showing whether a country is part of the EU. Then, you'll set up a Data Workflow to separate out countries that are part of the EU from those that are not.
Here's how the completed use case will look in the Module Editor:
Here's how the completed use case will work in Express View, including a peek at the DevTools Console:
What You'll Need
To set up this use case, you’ll need:
-
1 Data Table component
-
2 Hidden components
-
1 Data Workflow component
To set up your Data Workflow, you'll need:
-
1 Input operator
-
1 Filter operator
-
2 Output operators
Configure the Data Table Component
First, you'll set up your Data Table.
1. | Drag and drop a Data Table component onto your canvas. |
2. | Enter dtCountries in the Label and Property Name. |
3. | In the data table, enter the following: |
A |
B |
C |
---|---|---|
country |
capital |
memberOfEU |
Afghanistan |
Kabul |
No |
Albania |
Tirana |
No |
Algeria |
Algiers |
No |
Cambodia |
Phnom Penh |
|
Czechia |
Prague |
|
Andorra |
Andorra la Vella |
No |
Austria |
Vienna |
Yes |
4. | Click Save. |
Configure the Hidden Components
Before you can add your Data Workflow, you'll need a place to store its outputs. You'll use 2 Hidden components for that. Your filterTrue Hidden component will hold countries that are part of the EU. And your filterFalse Hidden component will hold countries that aren't part of the EU.
1. | Drag and drop 2 Hidden components onto your canvas. Place your Hidden components below your Data Table. |
2. | Enter the following Property IDs and Label Text: |
Property ID |
Label Text |
---|---|
filterTrue |
filterTrue |
filterFalse |
filterFalse |
3. | Save each component as you add it. |
Configure the Data Workflow Component
1. | Drag and drop a Data Workflow component onto your canvas. Place your Data Workflow above your Hidden components. |
2. | Enter dwfFilter in the Canvas Label Text and Property Name. |
Configure the Input Data Operator
1. | Drag and drop an Input operator onto your Data Workflow canvas. |
2. | Configure the Input operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Input |
Component |
dtCountries |
Required |
Yes |
Source |
Default |
Configure the Filter Operator
1. | Drag and drop a Filter operator onto your Data Workflow canvas. |
2. | Configure the Filter operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Filter |
Label |
Filter Members of the EU |
Do Not Sanitize Formula |
Yes (checked) |
Expression |
memberOfEU="Yes" |
3. | Connect the output port (right) of the Input operator to the input port (left) of the Filter Members of the EU Filter operator. |
Configure the First Output Operator
1. | Drag and drop an Output operator onto your Data Workflow canvas. |
2. | Configure the Output operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Output |
Component |
filterTrue |
Action |
value |
3. | Connect the upper output port (right) of the Filter Members of the EU Filter operator to the input port (left) of the filterTrueOutput operator. |
Configure the Second Output Operator
1. | Drag and drop a second Output operator onto your Data Workflow canvas. |
2. | Configure the Output operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Output |
Component |
filterFalse |
Action |
value |
3. | Connect the lower output port (right) of the Filter Members of the EU Filter operator to the input port (left) of the filterFalse Output operator. |
4. | Click Save. |
5. | Save your module. |
Now it's time to test your Data Workflow! Preview your module in Express View and then open the Console. You'll see your Hidden components now hold 2 different sets of countries: those a part of the EU and those that aren't. Compare these lists to what you entered in the Data Table. You'll see that the Filter operator separated the list just as expected.
Changing a Filter Operator's Settings
You can revisit and make changes to this operator.
1. | Click the Data Workflow component. |
A 5-button toolbar displays above the component on hover-over.
2. | Click the ![]() |
3. | Click the operator to open its Info Window. |
4. | Make changes to the operator's settings as needed. |
5. | Click Save. |
6. | Save your module. |
Copying a Filter Operator
You can make a copy of your operator using familiar keyboard settings. You can copy and paste an exact copy of your operator, matching all settings.
1. | Hover over the Data Workflow component. |
A 5-button toolbar displays above the component on hover-over.
2. | Click the ![]() |
3. | Click the operator you want to duplicate. |
4. | On your keyboard, press Command + C (Mac OS) or Ctrl + C (Windows/Linux) to copy the operator. |
TIP You can copy more than one operator at a time. Hold Command or Ctrl on your keyboard and click all the operators you want to copy. Follow the rest of the steps as usual.
5. | On your keyboard, press Command + V (Mac OS) or Ctrl + V (Windows/Linux) to paste the copied operator(s) to the Data Workflow canvas. |
6. | Click Save. |
7. | Save your module. |
TIP Did you know you can copy an operator and paste it into a different Data Workflow? You'll use the same steps outlined above.
Removing a Filter Operator
Lastly, you can delete this operator from your Data Workflow canvas. You can also use these same steps to delete a connection between two operators.
1. | Hover over the Data Workflow component. |
A 5-button toolbar displays above the component on hover-over.
2. | Click the ![]() |
3. | Click the operator you want to delete. |
4. | On your keyboard, press Delete. |
NOTE Once you delete this operator, make sure to connect your remaining operators. If your Data Workflow path doesn't end with an Output or Console operator, your Data Workflow won't work. So, once you delete an operator, make sure to update any remaining paths to end at an Output or Console operator.
5. | Click Save. |
6. | Save your module. |
Lab
You can view this complete use case here: https://training.unqork.io/#/form/5f4fe6801959bf0217f54722/edit.