Filter Condition
The filter condition is an expression that returns TRUE or FALSE.
Enter conditions in the Expression editor. The filter condition is case sensitive.
You can use any expression that returns a single value as a filter. For example, if you want to filter out rows for employees whose salary is less than or equal to $30,000, enter the following condition:
SALARY > 30000
You can specify multiple components of the condition, using the AND and OR logical operators. If you want to filter out employees who make less than $30,000 and more than $100,000, enter the following condition:
SALARY > 30000 AND SALARY < 100000
You can use ports, parameters, dynamic ports, and generated ports in the filter condition. Select the ports and the parameters in the Expression editor.
If you use a dynamic port in the filter condition, the filter condition expands to include all the generated ports in the dynamic port. For example, the dynamic port, MyDynamicPort, contains three decimal ports:
Salary
Bonus
Stock
If you configure the following filter condition:
MyDynamicPort > 100
The filter condition expands to the following expression:
Salary > 100 AND Bonus > 100 AND Stock > 100
You can enter a constant for the filter condition. The numeric equivalent of FALSE is zero (0). Any non zero value is the equivalent of TRUE. For example, the transformation contains a port named NUMBER_OF_UNITS with a numeric data type. You configure a filter condition to return FALSE if the value of NUMBER_OF_UNITS equals zero. Otherwise, the condition returns TRUE.
Note: You cannot use a single port selector or dynamic port as a boolean value.
You do not need to specify TRUE or FALSE as values in the expression. TRUE and FALSE are implicit return values from any condition you set. If the filter condition evaluates to NULL, the row is FALSE.
Parameterize the Filter Condition
You can configure an expression parameter to define the filter condition. An expression parameter contains the entire expression.
You might need to parameterize the filter condition when the Filter transformation is in a dynamic mapping. The filter condition might change based on the generated ports in the transformation at run time.
To use an expression parameter for the filter condition, choose Specify by Parameter on the Filter tab of the Filter transformation properties.
The following image shows the Filter tab when you specify the filter condition with a parameter:
You can browse for and select an expression parameter that you already created. Or, you can create an expression parameter.
To create an expression parameter, click New. Enter a name for the parameter, a description, and the default expression value.
The following image shows where you enter the parameter:
You can enter a default expression on the Parameters dialog box. If you want to use an Expression editor, click Edit. When you use the Expression editor, you can select functions and ports to use in the expression. You can validate the expression.
The following image shows the Filter tab with a parameter for the filter condition:
The expression parameter is a mapping parameter. You can override the parameter in a parameter set or a parameter file at run time.
Filtering Rows with Null Values
To filter rows containing null values or spaces, use the ISNULL and IS_SPACES functions to test the value of the port.
For example, if you want to filter out rows that contain NULL value in the FIRST_NAME port, use the following condition:
IIF(ISNULL(FIRST_NAME),FALSE,TRUE)
This condition states that if the FIRST_NAME port is NULL, the return value is FALSE and the row should be discarded. Otherwise, the row passes through to the next transformation.