DT.SELECT not working properly with AND operator

Ok let us do following, I do some simplification on your XAML will send you and then you can check the new code version and play around. OK for you?

I’m super okay with that, thank you so much!

@mickeymack
Just do some debugging and also inspect the output panel for the logs
In case of any open questions let me know, latest tomorrow I will answer
Here is the XAML: select_simple.xaml (11.3 KB)

Short Rework Feedback
Rule list are generated in a way that lists are ready for string contains check and empty values are no longer part of it

Filterstatement is shifted to LINQ
Filter logic:
If input row(Name) Value is not contained in R1 AND row(VALUE) Value is not contained in R2 THEN
row will be returned

(In case this requirement needs to be changed then we can work out)

If the filter action has an output then this will be written out, else it will warn logging do

1 Like

Thanks again. I’ll check it when I get home and let you know how it works out!

Had a chance to download your files and run. What you really want is if NAME is not in the name column OR VALUE is not in the value column. I also cleaned up the quotes a bit. Your r1_1 and _2 include what is needed.

db_in.Select(“NAME NOT IN (” + r1_1 + “) OR VALUE NOT IN (” + r1_2 + “)”).CopyToDataTable

Test_Output.xlsx (7.1 KB)

I didn’t download @ppr solution (saw too late) but you should take a look at it. I agree with him that using a list would be better and probably LINQ too.

Troy

@ppr - the code was a lot cleaner and more efficient, thanks. I’m wondering if I’m doing something wrong though, because when I run the code with ABC in Name and 123 in Value, with D1 in input_data, it’s still filtered.

Tried your solution, and that gives me what I want, though I’m not sure I understand why. Tried adding A4 and A5 to check and they’re kept. I’ll implement a mix of @ppr approach and your code. I’m also expanding it to some more columns in my actual implementation, but given the code you provided I think I’ll be able to build on that. Thanks so much; this has been really helpful!

Glad to help! :slight_smile:

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