Filter dataTable using select query

Hi All,
How do i use below query in uipath
Select col1 from dt where col2 =val;

Dt.Select() …i am not getting what to write inside ()

Check this , you will find the solution .

Thanks for quick reply …but i want only one column value …and with above select statement i guess it return all column value depending upon match condition

Between single quotes ’ ’ , you can pass your value that you want to check and it will return the row in which your particular column is matching the condition . Here column- will be your column name .

@TUSHAR_DIWASE,

Try like this

iterate Datable through for each row
If row(“col2”).Tostring = Value
then flag = 1
End If
if flag = 1
assign requiredValue = row(“col1”).Tostring
End If
End For Each

2 Likes

Thanks for this …but i want to achieve it with select statement

DataTable = DataTable.Select(“[Column Name] = ‘Value’”).CopyToDataTable

1 Like

i dont know what exact wrong i am doing. please find my wf.
i want depending upon department name i want to find all member present in it.Department List.xlsx (8.0 KB)
Main.xaml (21.0 KB)

@TUSHAR_DIWASE,

Change the filterData datatype from datarow to DataTable.

1 Like

I have mentioned data table here !!

1 Like

@lakshman @syedabidraza
yes, sorry for that . but still it give me all column matching data . I want only one column.
In my case i want only Employee name . and o/p coming is Employee name & department.
Using for each row i can filter it out. but my expectation is that with only select query i get employee name only :slight_smile:

Datatable.Rows(0).Item(0).ToString
Or
Datatable.Rows(0).Item(1).ToString

You can use one of it accordingly to get your desire value.

thank you so much for replying.
I will reframe my requirement.
Dept | EmpName
A | xyz
A | pqr
A | RST
B| efg
B | hij

Is it possible with select query that by passing dept name i will get all employee name present in it.
ex. if we pass A , then o/p will be
xyz
pqr
RST
with simple select query it gives Dept name and Employee name
A xyz
A pqr like wise ,i can filter out using for each . but just for knowledge i want it using select query if possible

@TUSHAR_DIWASE

image

DataTableFilter.xaml (9.5 KB)

The activity used in this workflow is Filter Data Table, with specific Column output defined.

I understood your requirement, you want to access the particular data without for each loop.
I will try step by step-

  1. firstly you have to select the rows which are having your department name.
  2. now you will be having a datatable , which is only having your particular department name and employee.
  3. now you can access any row or cell using
    Datatable.Rows(0).Item(0).ToString
    You can pass row and column here
1 Like

yes ,i really appreciate your response , but i want all name so after using select statement i get
A xyz
A pqr
A RST
but to get only (xyz ,pqr,RST) i have to use again for loop in above dt and get all values row(1).toSrting

But i want that is it possible with select statement that i will get directly all emp, name only.
like xyz
pqr
RST
Sorry for troubling . i want to find out is their any select statement to avoid for loop

sorry @hermawan ,this is not what i want . please see my latest reply :slight_smile: hope you will get idea .thanks

Check this , it’s similar with your solution .
Just “department” is replace by “country”

2 Likes

thank you so much.:slight_smile: