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 two output ports. One outputs the data matching your criteria. The other outputs data that doesn't match. You can make use of one 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 in the menu on the Data Workflow 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:

A static image displaying the Filter operator and its Settings 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 ', $, #, &amp. 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.

Preserve Argument Type

When selected, this setting ensures the argument data type is respected when the operator executes.

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 Builder:

A static image displaying the Filter operator completed use case in the Module Builder.

Here's how the completed use case will work in Express View, including a peek at the DevTools Console The DevTools Console helps you securely store, build, test, and deploy your software.:

Static image displaying the Filter operator use case data in the DevTools Console.

Configure the Data Table Component

First, you'll set up your Data Table.

1. Drag and drop a Dropdown Component Icon Data Table component onto your canvas.
2. In the Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module. and Canvas Label Text Canvas Label Text indicates the purpose of the corresponding field or component. For non-input components, the Canvas Label Text isn't end-user facing, and only appears in the . fields, enter dtCountries.
3. In the data table, enter the following: 

 

A

B

C

1

country

capital

memberOfEU

2

Afghanistan

Kabul

No

3

Albania

Tirana

No

4

Algeria

Algiers

No

5

Cambodia

Phnom Penh

 

6

Czechia

Prague

 

7

Andorra

Andorra la Vella

No

8

Austria

Vienna

Yes

A static image displaying the Data Table configuration in the Filter operator use case.

4. Click Save & Close.

Configure the Hidden Components

Before you can add your Data Workflow, you'll need a place to store its outputs. You'll use two Hidden components for that. Your filterTrue iconHidden component will hold countries that are part of the EU. And your filterFalse iconHidden component will hold countries that aren't part of the EU.

1. Drag and drop two iconHidden components onto your canvas, placing them below your dtCountries Dropdown Component Icon Data Table component.
2. Enter the following Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module.s and Canvas Label Text Canvas Label Text indicates the purpose of the corresponding field or component. For non-input components, the Canvas Label Text isn't end-user facing, and only appears in the .:

Property ID

Canvas Label Text

filterTrue

filterTrue

filterFalse

filterFalse

3. Save & Close each component as you add it.

Configure the Data Workflow Component

1. Drag and drop a Data Workflow Icon Data Workflow component onto your canvas, placing it above your iconHidden components.
2. In the Canvas Label Text and Property Name fields, enter dwfFilter.

Static image displaying the Data Workflow configuration for the Filter operator use case.

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)

Preserve Argument Type

Unchecked (no)

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.

To test your Data Workflow, Preview your module in Express View Express View is how your end-user views you application. Express View also lets you preview your applications to test your configuration and view the styling. This is also the view your end-users will see when interacting with your application. After configuring a module, click Preview in the Module Builder to interact with the module in Express View. and then open the DevTools Console The DevTools Console helps you securely store, build, test, and deploy your software.. You'll see your Hidden components now hold two 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.

Resources