Hi everyone! I looked around for this topic and couldn’t find anything applicable. I wanted to check a datatable and quickly see if values other than the ones below are found in a specific column, and return a boolean. I tried doing a for each row but it doesn’t seem to be the very efficient. Please let me know if there might be another solution.
Here is the criteria:
does not start with “11”
does not start with “22”
does not start with “33”
does not equal variable1
True: a value other than those 4 is found in the column
False: no other value (other than those 4) is found in the column
I tried this in an IF condition, but it’s not allowing me to add additional conditions: dt.AsEnumerable().Any(Function(x) Not x(“Column-1”).ToString.StartsWith(“11”))
dt.AsEnumerable().Any(Function(x) Not (System.TExt.RegularExpressions.Regex.IsMatch(x("Column-1").ToString,"^(11|22|33)") OrElse x("Column-1").ToString=variable1))
(From d in dt.AsEnumerable
Let c1 = Not {"11","22","33"}.Any(Function (c1) d("Column-1").toString.Trim.StartsWith(c1))
Let c2 = Not d("Column-1").toString.Trim.Equals(variable1)
Let res = {c1,c2}.All(Function (r1) r1)
Select fc = res).Any(Function (x) x)
Feel free to adopt / finetune it by using All / Any on the particular checks
Yes this definitely helps! Thank you!! Do you mind clarifying one more thing? Does the expression you provided return a TRUE if there is just one row which does not start with 11, 22, etc.?
For me i am able to filter it my end. not sure what is the syntax you are getting. Please follow the multiple suggestions from our forum members and see which one fit better follow that. if you want you could review the attached the sample process i have created. thanks.