Filter datatable with LinQ


I have a dtatable that i want to filter for a certain date and also certain countries. Below is my linq statement but i keep only getting results that matches USA. I know for a fact that there is canda in the dataset, What am i doing wrong

(From d In dt_cci.Select()
Let dp = CDate(d("oin Date").ToString.Trim).Date
Where (dp > filterDate And d("Country Name").ToString.ToLower.Trim.Equals("usa")) Or 
(dp > filterDate And d("Country Name").ToString.ToLower.Trim.Equals("canada"))
Select r = d).CopyToDataTable
1 Like


Can you share your input and expected result?



Why don’t you try with Filter Datatable activity?

But it’s better if you can share the sample Input, Output files

Then we can got to know the exact issue


In above Linq Query you put OR condition whenever usa found query return the reasult.
can you please just remove usa field from datatable then try once

Try This :

dt_cci.AsEnumerable.Where(Function(d) (CDate(d(“oin Date”).ToString.Trim).Date> filterDate.Date And d(“Country Name”).ToString.ToLower.Trim.Equals(“usa”)) Or (CDate(d(“oin Date”).ToString.Trim).Date> filterDate.Date And d(“Country Name”).ToString.ToLower.Trim.Equals(“canada”))).ToArray.CopyToDataTable