How to do this filtering case in uipath

how to select only
Book1.xlsx (12.5 KB)
from sheet2 the values should enter in sheet one
the grouping should be done to the dept and it should only takes IT dept

Hi @anjani_priya

Try this

Code:

(From row In DT1.AsEnumerable()
                Where row.Field(Of String)("dept") = "IT"
                Select row).CopyToDataTable()

O/P:
Book1 (6).xlsx (12.6 KB)

Hope this helps!!

Do you need only IT dept?
If so, the following will work.

arrDr = dt.AsEnumerable.Where(Function(r) r("dept").ToString="IT").ToArray

dtResult = arrDr.CopyToDataTable.DefaultView.ToTable(False,{"name","age","salary","dept","Location"})

Sample20231026-3L.zip (11.8 KB)

Regards,

if we want only name and age how to filter that?in IT dept

iam getting the error that any is not the member of datatable

Hi,

Can you check the above sample (zip file?)

Also check typeof arrDr. It should be datarow array type.

Regards,

in sheet2,the data of bang location shouldnot be considered?how to do

HI,

Can you try the following expression?

arrDr = dt.AsEnumerable.Where(Function(r) r("dept").ToString="IT" AndAlso r("location").ToString<>"BANG" ).ToArray

Sample20231026-3L (2).zip (21.0 KB)

Regards,

salary should be in int
how to mention?

Hi,

Can you elaborate?

Regards,

dtResult = arrDr.CopyToDataTable.DefaultView.ToTable(False,{“name”,“age”,“salary”,“dept”,“Location”})
in this salary should be in integer

HI,

In my environment, salary is integer as the following. Do you have any problem?

image

Regards,

requirement is different
Book1.xlsx (12.7 KB)
this is the input
in need the data only the dept IT and location bang should not consider and output should show only name and salary
Capture17
this is the output
i kept filters for location and dept

HI,

How about the following sample?

dtResult = arrDr.CopyToDataTable.DefaultView.ToTable(False,{"name","salary"})

Sample20231026-3L (3).zip (23.5 KB)

Regards,

iam getting error that dept doesnt belong to datatable

Hi,

Which sheet did you read? From Sheet2?

Regards,

yes.from sheet2 to sheet1 but in sheet1 dept column should not display so i removed so that the error displayed

HI,

Did you try the above Sample20231026-3L (3).zip?
Does it works? (result.xlsx will be output)

Regards,

Hi,

It seems not same as my expression. (There is no “Gropuing” in my expression)

Regards,