Filter Column That Column Name Contain Key Word

Hi everyone,

I need to filter a datatable by its columns names.

Only columns that contain “NETPR” in the column name should remain. The other columns should be deleted. Anyone know how can I do that?

1 Like

@mazlumkacar

  1. Use Read Range activity to read the data from excel file and store output in inputDT.

  2. And then try below expression to filter the data from given DataTable.

         filterDT = inputDT.Select("ColumnName = 'NETPR'").CopyToDataTable
    
  3. And then use Write Range activity to write into Excel file and delete existing sheet.

Hello @mazlumkacar,
You can do something similar to below image: (Please change DataType for “item” variable.

3 Likes

Thanks a lot @Bhavik_Solanki. But should i create a variable named “ColumnName” for this process?

Because i have no a spesific column name in this process. I need to remove those columns by its name.

@mazlumkacar , No you don’t have to. It is in-build property of DataColumn. As I mentioned in my previous post don’t forget to change the DataType of the “item” variable.

Here is screenshot for your reference. Click on For Each activity and update value.

1 Like

Thanks again @Bhavik_Solanki . But i am getting this error when i try to do this.

@mazlumkacar
Sorry for the late response. There is minor correction in above workflow. in For Each Activity, just replace “dt_httpresult.Columns” with “dt_httpresult.Copy.Columns” and it should work.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.