# Build and Filter DataTable

> Filter and extract data from a DataTable.

The example below explains how to filter and extract data from a DataTable by using [**Build Data Table**](https://docs.uipath.com/activities/other/latest/workflow/build-data-table), [**Filter Data Table**](https://docs.uipath.com/activities/other/latest/workflow/filter-data-table), [**Output Data Table**](https://docs.uipath.com/activities/other/latest/workflow/output-data-table), [**For Each Row**](https://docs.uipath.com/activities/other/latest/workflow/for-each-row), and [**Get Row Item**](https://docs.uipath.com/activities/other/latest/workflow/get-row-item) activities. You can find these activities in the **UiPath.System.Activities** package.

This is how the automation process can be built:

1. Open Studio and create a new **Process**.
2. Drag a **Sequence** container in the **Workflow Designer**.
   * Create the following variables:

     | Variable Name | Variable Type | Default Value |
     | --- | --- | --- |
     | `DT1` | **DataTable** |  |
     | `DT2` | **DataTable** |  |
     | `DataTableString` | **String** |  |
3. Drag a **Build Data Table** activity inside the **Sequence** container.
   * In the **Properties** panel, add the variable `DT1` in the **DataTable** field.
   * Click the **DataTable** button. The Build Data Table window contains a table with two columns and rows.
   * Click the **Add Column** button and add a new column.
   * Click the **Edit Column** button from the first column and add the value `Name` in the **ColumnName** field.
   * Select the **String** option from the **Data Type** drop-down list.
   * Select the check box for the **Allow Null** option.
   * Add the value `-1` in the **Max Length** field.
   * Click the **OK** option for closing the window.
   * Click the **Edit Column** button from the second column and add the value `Surname` in the **ColumnName** field.
   * Select the **String** option from the **Data Type** drop-down list.
   * Select the check box for the **Allow Null** option.
   * Add the value `-1` in the **Max Length** field.
   * Click the **OK** option for closing the window.
   * Click the **Edit Column** button from the third column and add the value `Grade` in the **ColumnName** field.
   * Select the **Int32** option from the **Data Type** drop-down list.
   * Select the check box for the **Allow Null** option.
   * Add the value `-1` in the **Max Length** field.
   * Click the **OK** button for closing the window.
   * Click the **OK** button again.
   * This is how the DataTable window should look:

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/activities-docs-image-183465-cb5ce79f.webp)
4. Drag a **Filter Data Table** activity below the **Build Data Table** activity.
5. Click the **Filter Wizard** button.
   * Add the variable `DT1` in the **Input DataTable** field.
   * Add the variable `DT2` in the **Output DataTable** field.
   * Select the **Keep** option for the **Rows Filtering Mode** field.
   * Add the value `"Grade"` in the **Column** field.
   * Select the **&lt;** value from the **Operation** drop-down list.
   * Add the value `5` in the **Value** field.
   * Click the **Output Columns** tab.
   * Select the **Keep** option for the **Columns Selection Mode** field.
   * Add the columns **"Name"** and **"Surname"**.
   * Click the **OK** button.
   * This is how the Filter Wizard should look:

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/activities-docs-image-179756-c4515b2e.gif)
6. Place an **Output Data Table** activity below the **Filter Data Table** activity.
   * In the **Properties** panel, add the variable `DT2` in the **DataTable** field.
   * Add the variable `DataTableString` in the **Text** field.
7. Drag a **Write Line** activity below the **Output Data Table** activity.
   * Add the variable `DataTableString` in the **Text** field.
8. Place a **For Each Row** activity below the **Write Line** activity.
   * Add the variable `DT1` in the **DataTable** field.
9. Select the **Body** container and create the following variable:

   | Variable Name | Variable Type | Default Value |
   | --- | --- | --- |
   | `Grade` | **Int32** |  |
10. Add a **Get Row Item** activity and place it inside the **Body** container.
    * In the **Properties** panel, add the value `"Grade"` in the **ColumnName** field.
    * Add the value `row` in the **Row** field.
    * Add the variable `Grade` in the **Value** field.
11. Place an **If** activity below the **Get Row Item** activity.
    * Add the expression `Grade < 5` in the **Condition** field.
12. Drag a **Write Line** activity inside the **Then** field.
    * Add the expression `"Failed:" + row("Name").ToString + " " + row("Surname").ToString` in the **Text** field.
13. Run the process. The robot extracts all data meeting the requirements. This is how your workflow should look:

    ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/activities-docs-image-179620-30987add.webp)

[Here](https://docexamples.uipath.com/examples/Activities/Build%20and%20Filter%20DataTable%20-%20Example.zip) you can download an example.
