Filter DataTable by two options in the same Column


#1

Good afternoon,

I have a doubt and I would be glad if someone could help me.

I’m trying to filter a DataTable (Excel Sheet) that has a total of 5 columns, by one of the columns.

That column can have the values A,B or C. I only want to keep the rows with value A and B.

I tried the “Filter” Excel activity but when I do “Read Range” in that sheet after, despites the Filtering he still gets the other values with C in the Column…

Thank you for your attention,

Best Regards,

Miguel Pontes


#2

Use DataTable.Select function. Make it like this:

dtOut.Select(([Your_Column] LIKE ‘A’ or [Your_Column] LIKE ‘B’ or [Your_Column] LIKE ‘C’))

This way you can aggregate rules inside rules. If you have “Your_Column2” and want to apply a filter in that too you can do that this way:

dtOut.Select(([Your_Column] LIKE ‘A’ or [Your_Column] LIKE ‘B’ or [Your_Column] LIKE ‘C’) AND [Your_Column2] LIKE ‘AAAA’ AND ([Your_Column3] LIKE ‘YY’ or [Your_Column3] LIKE ‘XX’))

A good pratice is aggregate the filters by columns. More readable.

Cheers,
Renato Q


#3

Hi @mikePontes

please refer below xaml.
FilterTableExample.xaml (6.9 KB)
ExcelTable.xlsx (9.7 KB)

Regards,
Arivu


#4

Hi @mikePontes,

instead of excel filter activity you can use read range to get the all the data(dtresult).
after that you can filter using select statement
dtresult=dtresult.select("[columnname]<>‘C’")

Regards,
Arivu


#5

Hi @arivu96,

In the above example, U mentioned Table3.
What is that?

Regards,
Abi


#6

can you give an example ?


#7

@Abishek : he mention Table Name

In Excel On the Ribbon, under the Table Tools tab, click the Design tab. you can see Table Name there


#8

@KinjalRD
@Chand
@Abishek
@arivu96
Hello , Help me plz

I need to filter the Data table with multiple filter values/arguments ,

I tried below syntax, but getting error .Please let me know any one.

I’m uploading some images for references(Actually I need to filter more than 5 values )

multipleImage2


#9

@ChinnapuReddy check if the result contains any DataRow, if yes then you could call the CopyToDataTable