DataTable.Select not working

datatable
selector

#1

Hi.
I’m trying to filter a datatable using the “Select” function.

This is my select:

“dtOut.Select(”[Customer] NOT LIKE ‘0%’ and [WBS Element] NOT LIKE ‘’ and [Net Sales]>‘0’ and [Profit center] LIKE ‘1111’ or [Profit center] LIKE ‘2222’ or [Profit center] LIKE ‘3333’ or [Profit center] LIKE ‘4444’ or [Profit center] LIKE ‘5555’ or [Profit center] LIKE ‘6666’").CopyToDataTable

and the studio gives me no error. But when I open the excel file, where I make a write range with the selector result, the data does not respect my filter.

I’ve already tested the filter step by step, with each filter isolated and all of them Works! But when I make it all together for some reason it stops working.

Anybody can help me?? Thank you all.


#2

Hi @Renato_Quintal,
Try like this.

dtOut.Select(”[Customer] NOT LIKE ‘0%’ and [WBS Element] NOT LIKE ‘’ and [Net Sales]>‘0’ and ([Profit center] LIKE ‘1111’ or [Profit center] LIKE ‘2222’ or [Profit center] LIKE ‘3333’ or [Profit center] LIKE ‘4444’ or [Profit center] LIKE ‘5555’ or [Profit center] LIKE ‘6666’)").CopyToDataTable

Regards,
Arivu


#3

Are you sure it worked without ‘%’ for Like Operator?


#4

Hi,
@vvaidya & @Renato_Quintal

If u not giving ‘℅’ or ‘_’ then it’ll consider as equal to.(exact match)

Regards,
Arivu


#5

Yes and since the query has AND operators, most likely that’s the reason the Select statement is returning 0 rows. Besides the brackets you mentioned in your post.


#6

Hi,
@vvaidya & @Renato_Quintal
Yes if it’s all the condition matches then only it ll return the value otherwise returns 0 rocords only.

Regards,
Arivu


#7

Thank you! That solved my problem. Isolating the Profit Center solved everything.