Read 2 dataTable if id matched that enter the column from dt2 to dt1

image

This is first image

image
this is second image.

I have saved these two excel sheet in two different DataTables. now i want to compare both data tables and if dt2 contains the employee_id of dt1 than the amount of that particular employee_id should be added in dt1…

Thanks in advance

@Rahul_Jawahirani First Add Data Column as ‘Amount’ to DT1
Next you need to Have two For Each Rows to loop through 2 Datatables
Next Inside For Each Compare DT1’s ID with DT2
If it mAtches,
Add the Value of that Corresponding Amount to the DT1’s Amount Column

Hi
welcome to uipath community
hope these steps would help you resolve this

  1. use a excel application scope and pass the filepath of excel as input and inside the loop use a READ RANGE activity and get the output with a variable of type datatable named dt1

  2. now use another excel application scope and pass the filepath of second excel and inside that scope use read range activity and get the output with a variable of type datatable named dt2

  3. then use a ADD DATACOLUMN activity and pass the columnname as “Amount” and datatable as dt1

  4. use a FOR EACH ROW activity and pass the input as dt1
    and inside the loop use LOOKUP DATATABLE ACTIVITY and mention the input like these
    input = row(0).ToString
    input datatable = dt2
    Target column name = “Amount”
    Lookup columnname = “Employee Id Check”
    result = stroutput

next to this lookup datatable activity use assign activity like this
row(1) = stroutput
this will assign the corresponding value to that column
now we can use WRITE RANGE activity to pass the above variable dt1 as input and write that back tothe excel file 1

Cheers @Rahul_Jawahirani

2 Likes

hiee thanks for replying…

As you have mentioned the steps, i have done all these things previously itself but stuck somewhere in lookup activity…
now trying to do lookup activity as u have said…

Thanks Rahul

1 Like

cheers @Rahul_Jawahirani

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.