How to select values based on two column conditions in a Datatable

HI there,
I want to extract values from a DataTable based on Condition that Column1 contains value “abc” and Column 2 contains value"123".

Also How to add variables in the Query contaning the values.(eg: variable “name” storing the value “abc”)

Example: below query searches in DT based on one column value. I need search for 2 coulmn values
I know x = Datatable1.Select("[Column_Name] =’" + Column_Value.ToString+"’")

Hi @shalu.mittal
You can try filter datatable activity or below linq query

using assign activity

dt1 = dt1.AsEnumerable().Where(Function(row) row(Column1).ToString.Contains(“abc”) And row(Column2).ToString.Contains(“123”)).CopyToDatatable

Here finally u will get filtered dt2 which contains the required values basd on condition from there whcih u can extract the required values

Mark it as solution if it resolves ur query

Regards
Nived N

Happy Automation

1 Like

@NIVED_NAMBIAR Thanks for the reply. If i want to add Variable instead of Value "abc " and “xyz”. How to do that

dt1.AsEnumerable().Where(Function(row) row(YourCol1NameOrIndex).ToString.Contains(YourVar1) And row(YourCol2NameOrIndex).ToString.Contains(YourVar2)).CopyToDatatable

handling empty result can be done with following pattern:

1 Like