The Filter Transformation in Informatica is used to filter the records based on the specified expression/condition. The Filter condition return Boolean TRUE or FALSE, it means integration service will check each row against the specified condition. And if the condition is TRUE then the Informatica Filter transformation will pass the row otherwise, it will skip the current row and check the next one.
Filter Transformation in Informatica is very helpful in real-time. For example, If you want to load the customer data whose sales value is above the minimum threshold etc. In this article, we are going to perform Filter Transformation on two SQL tables.
For this Informatica Filter Transformation example, we are using the [Dim Products] and [fact Internet Sales] tables from our [Adventure Works DW 2014] database.
Filter Transformation in Informatica Example
Before we start doing anything, First connect to the Informatica repository service with your Admin Console credentials.
Create an Informatica Filter Transformation Source Definition
Once you connected successfully, Please navigate to Source Analyzer and define your Sources. In this Informatica Filter Transformation example, we are using [Dim Products] and [fact Internet Sales] from the SQL Server database as our source definitions. Please refer to Database Source to understand the steps involved in creating a source definition
Creating a Target Definition for Filter Transformation in Informatica
Please navigate to Target Designer and define the Target. In this Informatica Filter Transformation example, we are using the already created SQL table (Filter Transformation) as our target definition. Please refer Create Target table using Source Definition to understand the steps involved in creating a target definition
Create a Mapping for Filter Transformation in Informatica
In order to create a new mapping for Informatica Filter Transformation, Please navigate to Mappings menu in Menu Bar and select the Create.. option. This will open the Mapping Name window as shown below. Here, you have to write a unique name for this mapping (m_Filter_Transformation) and click OK button.
TIP: Please refer Mapping article to understand the steps involved in creating Mapping.
Next, Drag and drop the [Dim Products] and [fact Internet Sales] source definitions from Sources folder to the mapping designer. Once you drag the source, PowerCenter Designer will automatically create the default transformation called source qualifier as we shown below.
As we all know that the [Dim Products] and [fact Internet Sales] tables have the Primary and Foreign key relationship. So, we removed one source qualifier and added the required fields from both tables to single source qualifier.
Creating a Filter Transformation in Informatica
In order to create Filter transformation in Informatica, Please navigate to Transformation menu in Menu Bar and select the Create.. option as we shown below.
Once you click on the Create.. option, Create Transformation window will be opened as shown below. Please select the Filter Transformation from the drop-down list and specify the unique name (fil_SalesAmount) for it and click on Create button
Once you click on the Create button, filter transformation will be added to the mapping designer. In order to filter the records by an expression, filter Transformation requires some data. So, we have to connect the Source definition with the transformation using Autolink.. option (or select and Drag required fields).
Double click on the Filter transformation to provide the filter condition. From the below screenshot you can see the list of available properties in the Transformation tab:
- Select Transformation: By default, it will select the transformation you clicked on.
- Rename: This button will help you to rename the filter transformation to a more meaningful name.
- Make Reusable: If you check mark this option then, this transformation will become reusable transformation.
- Description: Please provide a valid description of this transformation.
Below screenshot will show you the list of available options in the Informatica Filter Transformation Ports tab:
- Port Name: List of available column names. By clicking the New column button you can add new columns and by clicking the scissors button you can delete the unwanted columns.
- I: Columns that are check-marked under this section are the filter transformation Input columns.
- O: Columns that are check-marked under this section are the filter transformation Output columns. If you unchecked any column then, that column will not be available to load in a target table.
The following screenshot will show you the list of available options in the Properties tab. By default Filter Condition will be set to TRUE and here only we have to provide the condition. In order to specify the condition, click on the Arrow button as shown below.
TIP: If you specify the Filter Condition to FALSE then filter condition will not allow single record.
Once you click on the arrow button, Expression Editor window will be opened as shown below. Here you can write custom expressions using the available functions, Ports (Column Names) and Variables.
For this example, we are using the simple expression i.e., SalesAmount > 2000. It means Informatica Filter transformation will return the records whose sales amount is greater than 2000
Once you finish configuring the properties, Click OK to close the transformation window.
Next, Drag and drop the target definition (Filter Transformation in Informatica) from the Targets folder to the mapping designer and connect the Transformation with the target definition. Please use the Autolink.. option to connect them.
Before we close the Mapping, Let us validate the mapping by going to Mapping Menu bar and selecting the Validate option.
Create an Informatica Filter Transformation Workflow
Once we finish creating the Mapping we have to create the workflow for it. PowerCenter Workflow manager provides two approaches to create a workflow.
In this Informatica Filter Transformation example, we will create the Workflow manually. In order to create a new Workflow, Please navigate to Workflows Menu and select the Create option. This will open Create Workflow window as shown below. Please provide the unique name (wf_Filter_Transformation) and leave the default settings.
Once we created the workflow, our next step is to create a session task for our mapping.
NOTE: We strictly recommend to refer Workflow article to understand the steps involved in creating Workflow manually.
Creating a Session
There are two types of sessions:
- Non-reusable Session Task: Please refer Session
- Reusable Session Task: Please refer Reusable Session
For this Informatica Filter Transformation example, we are going to create Non-reusable Session. Please navigate to Tasks Menu and select the Create option to open the Create Task window. Here you have to select the Session as Task type (default) and enter a unique name (S_Filter_Transformation) for the session.
Once you click on the Create button, a new window called Mappings will be opened. Here you have to select the mapping you want to associate with this session. From the below screenshot you can observe that we are selecting the mapping (m_Filter_Transformation) that we created earlier (in Step 3).
Double click on the Session Task to configure it. Although we have to configure Sources, targets, and some common properties, we are explaining only a few properties. We strictly recommend visiting the Session article to understand the remaining properties.
From the below screenshot you can observe that we assigned the $target variable to Connection Value, we changed the Target Load Type option from Bulk to Normal mode and check marked the Truncate target table option to truncate the existing data from the destination table.
From the below screenshot you can observe that the Filter Transformation in Informatica workflow is a valid one. Now, Let us start the Workflow by navigating to Workflows menu and selecting the Start Workflow option.
Once you select the Start Workflow option, the PowerCenter Workflow monitor will be opened to monitor the workflow. From the below screenshot you can observe that our workflow is executed without any errors.
Let us open the SQL Server Management Studio to check whether we successfully restricted the records with Sales Amount less than 2000 using the Informatica Filter Transformation or not.