How to Filter Two or More Items from a columns in Datatable

Hi team,

I want to filter to retailers from my “Customer Name” columns while I want to keep just one filtering condition for other columns-- Here is the current
Expression for my filter
dt_DataSource.AsEnumerable.where(function(x) x(“Customer Name”).ToString.Equals(“PACIFIC SUNWEAR OF CALIFORNIA” ) And x(“Warehouse Id”).ToString.Equals(“09”) Andalso DateTime.parseExact(x(“Start Dt”).ToString,“MM/dd/yyyy 00:00:00”,system.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”).Equals(“01/04/2023”)).CopyToDataTable
I want to filter “PACIFIC SUNWEAR OF CALIFORNIA” and “CALISUN” from the “Customer Name” while the filter condition for other columns remain the same as you see in the above.

Thanks a lot!

dt_DataSource.AsEnumerable.where(function(x) (x(“Customer Name”).ToString.Equals(“PACIFIC SUNWEAR OF CALIFORNIA” ) orElse x(“Customer Name”).ToString.Equals(“CALISUN”)) AndAlso x(“Warehouse Id”).ToString.Equals(“09”) Andalso DateTime.parseExact(x(“Start Dt”).ToString,“MM/dd/yyyy 00:00:00”,system.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”).Equals(“01/04/2023”)).CopyToDataTable

Hi @Yameso Thank you your time.
With the expression you just sent me.
The second customer did not return. Aslo, it returned data from another Warehouse Id.
Can you look into it once more? Thanks!

give a try at:

(From d in dt_DataSource.AsEnumerable
Where {"PACIFIC SUNWEAR OF CALIFORNIA","CALISUN" }.Any(Function (x) d("Customer Name").ToString.Trim.ToUpper.Equals(x))
Where d("Warehouse Id").ToString.Trim.Equals("09") 
Where CDate(d("Start Dt").ToString).Date.Equals(CDate("04/01/2023").Date)
Select r =d).CopyToDataTable

@ppr

I think the above expression has compiler’s error!
It alarts error

@ppr

What is the variable x
Equals(x))
seems has not been declared. Thanks!

updated the statement

That’s already part of the expression/ Query.

Yes the corrected one


Also validating

Hi @Sisay_Dinku
Give a try to this.

dt_DataSource.AsEnumerable.where(function(x) (x(“Customer Name”).ToString.Equals(“PACIFIC SUNWEAR OF CALIFORNIA”) Or x(“Customer Name”).ToString.Equals(“CALISUN”)) And x(“Warehouse Id”).ToString.Equals(“09”) Andalso DateTime.parseExact(x(“Start Dt”).ToString,“MM/dd/yyyy 00:00:00”,system.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”).Equals(“01/04/2023”)).CopyToDataTable

Hope this helps

@ppr
Thank you, the error has gone but I still see data from only one customer.
What could be the cause?
I want to get data from the two customers but from the same Warehouse Id.
every time we make the combination of customers, we fix the warehouse Id to the same.
Sample_Data.xlsx (15.3 KB)

Thank you!

@Suraj_B_Shetty I gave that a try, it did not return data for both customers.
Thanks!

When shared excel is the source:
grafik

there are no CALISUN customers

@ppr This is another sample data. you can choose any of the two customers and return data from both.

@ppr
you can choose
“PACIFIC SUNWEAR OF CALIFORNIA” and “URBAN OUTFITTERS INC.”

we can better support when working with the same sources

As an alternate you can check the filtering on a smaller test set where the result is better to force for the testing

Hi @Sisay_Dinku

I was able to get the both data using same query. Check this workflow.
Sequence1.xaml (6.6 KB)

Output - refer sheet1
Sample_Data.xlsx (16.6 KB)

Hope this helps

@Suraj_B_Shetty In my case, I keep on getting data only from the one customer. Can you take the other ones and give it a try?

@Sisay_Dinku

Share the input file which you are using and names to be filtered.