Using if condition need to filter out and extract that filter data into another sheet in excel

Hello,
can anyone help me to create a workflow.
condition should be like this–>if this condition is true (Amount Spend >= Amount Allotted) then i need to extract that true data from excel sheet1 to sheet2 then need to send mail to one person with attached file.
Thanks in Advance…Capture

Hi @ashwini_avula
welcome to forum

you can try this using linq query too

steps to be followed.

a. Read the excel and store in dt1 variable using read range.

b. build a datatable with required columns using build datatable activity and store in dt2

c . now use assign activity with below linq query

dt2 = (From row in dt1.AsEnumerable
Where CInt(row("Amount_Spend))>CInt(row(“Amount_Alloted”))
Let r1 = row.ItemArray
dt2.Rows.Add(r1)).CopyToDataTable

Try this way and let me know if it works

Regards,
Nived N
Happy Automation

1 Like

Hello Nived,
I appreciate for your quick reply but I am getting error in assign activity. Can you check and update once.
Thanks…

@ashwini_avula

Try below expression

varDT.AsEnumerable.Where(function(r) cdbl(r("Amount_Alloted").ToString)>=cdbl(r("Amount_Spend").ToString)).CopyToDataTable

@ashwini_avula

Find attached below for reference

Excel.xaml (7.1 KB)

what is that cdbl would you please explain that code

It is converting string to double

2 Likes

Hello Pravin,
Can you explain this expression varDT.AsEnumerable.Where(function(r) once.
Thanks in advance…

@Swetha_V AsEnumerable method gives you the rows collection and we are filtering it with conditions…It is the best way to avoid for each row.

In other ways, UiPath made a document also.

Refer to the below link for more information.

Hi Pravin,
Error showing in Assign activity. Could you help with this once?

Add new System.Data.Datatable in both variables default value

Could you check this error once

Hi check with this query

Hello Pravin,
I am unable to filter the Allowed data to a different sheet. Can you help me with that?

Error3

Thanks in Advance…

@Swetha_V With filter data table activity are you getting any error or just an empty data table in return?

The select query for your solution would be like below.

Dt.Select("Status='Allowed'").CopyToDataTable
1 Like

Hello,
Can anyone help me with this error?
Capture
Thanks in advance…