Filter Datatable by using AND function

I have few keywords which needs to be filtered out from a specific single column from an excel sheet and write the output in a new excel sheet. I am using read range workbook, storing in an datatatble and using filter datatable and in that filter Datatable i am using AND function but i coudnt get the output in a new sheet
Please help me resolve this.

Thanks

Hi @Mayur_N

If possible can you share sample excel file and what you want to filter.

Regards,

I am a new user so I couldn’t upload any file.

I have a bank statement, in that bank statement I have a specific column named “Description” from which i need to filter out the rows which is having 5 different keywords and write it into a new excel sheet

Hi @Mayur_N

Are you getting a filtered data after the filter activity. You can check the datatable in the immediate panel.

If you are getting the correct data. Then you can use Write datatable to excel activity to write it to new Excel sheet.

For ref: https://forum.uipath.com/t/how-extract-important-data-from-excel-cell/701365/8

Hope this helps :slight_smile:

Hi @Mayur_N

You can use Filter DataTable

  1. Read range
  2. Filter DataTable
  3. Write Range

Hi @Mayur_N

Use OR Condition for all your Keywords.

Hope it will helps you :slight_smile:
Cheers!!

Thank you, I got the preferred output!

Awesome. If my reply helped you can mark it as a solution. So that it can help others also find solution.

@Mayur_N

If it was a single column, you would need to utilize the ‘OR’ function .
Syntax, which is

dt=dt_excel.AsEnumerable.where(function(x) x(“ColumnName1”).ToString.ToLower.Equals(“KeyWord”) or x(“ColumnName1”).ToString.ToLower.Equals(“KeyWord”)).copytodatatable

Cheers!!

@Mayur_N

you have a DataTable named inputDataTable and you want to filter out rows where a specific column (let’s say “ColumnName”) does not contain certain keywords, and then write the output to a new Excel sheet

outputDataTable = inputDataTable.AsEnumerable().Where(Function(row) Not {"Keyword1", "Keyword2", "Keyword3"}.Any(Function(keyword) row.Field(Of String)("ColumnName").Contains(keyword))).CopyToDataTable().WriteRange("OutputFilePath.xlsx", "SheetName")

cheers…!!!

1 Like

AND would mean all the conditions must be true for them to be filtered out. If you’re trying to filter it out if it’s one of a certain list of values, use OR not AND. ie SomeVar = “Value1” OR SomeVar = “Value2”

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