How to lookup two data tables?

Hi,

I have 2 excel sheets, one with 4 rows and other with 6 rows, I want to get all the rows from sheet1 and the not matching extra rows from sheet2 and paste the combination of both in sheet3.

please assist in how to achieve this scenario… thank you so much in advance.

@aishwarya1

Welcome to our UiPath community.

Use Join DataTable activity to do this.

Have a look below thread.

Hi @aishwarya1
Welcome to forum

For your question i am assuming that

dt1- datatable after reading sheet1

dt2- after reading sheet2

Now to get uncommon rows from dt2 use the below linq

dt_uncommon=  dt1.AsEnumerable().Except(dt2.AsEnumerable(),System.Data.DataRowComparer.Default).CopyToDataTable**

now append the dt1 and dt_uncommon in same excel sheet using append range or merge datatable activity

Regards,
Nived N

1 Like

Is there a way to compare only one column between the datatables?

this is sheet1

image

this is sheet 2

I want the output as below

image

Please assist

Hi @aishwarya1
u can try this

assume
dt1 —> sheet1

dt2 -----> sheet2

dt3_uncommon= (From r1 in dt2.AsEnumerable

Where dt1.AsEnumerable().Where(Function(row) row(“Organization Name”).ToString.Trim.Equals(r1(“Organization Name”).ToString)).Count=0
Select r1).CopyToDataTable

Now use append range or merge datatable to merge the dt1 and dt3_uncommon to a excel sheet.

Regards,
Nived N

3 Likes

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