Compare DataTable

I have two datatable : one with 6 columns and another one with 11 columns.

I want to create a thrird DT with the row of the 2nd datable if the first 4 columns of the second Datatable is equal to the first 4 columns of the first Datable.

I tried a lot of different method but I need your help…

welcome to uipath community
hope these steps would help you resolve this
–using BUILD DATATABLE activity create a datatable with same column structure of any of the datatable and get the output with a variable named FinalDt
–lets take like we have two datatables named dt1 and dt2
–now use a for each row activity and pass the variable dt1 as input and change the variable name from row to row1
–inside the loop use another for each row loop and pass the variable dt2 as input and change the variablename from row to row2
–now inside this inner for each row loop use a IF condition like this
row2(0).tostring.Equals(row1(0).tostring) AND row2(1).tostring.Equals(row1(1).tostring) AND row2(2).tostring.Equals(row1(2).tostring) AND row2(3).tostring.Equals(row1(3).tostring)

if this is true it will go to THEN part where we can leave use a ADD DATA ROW activity and in the property panel we can mention as row1.ItemArray in the ArrayRow property and in the datatable mention as FinalDt
which will add the datarow to the FinalDt when the rows of specific matches between two datatable
if not it will go to ELSE part where we can leave it empty

–followed by this add data row activity use a BREAK activity to stop looping once after the match is found

kindly try this and let know for any queries or clarification
Cheers @Pierre_PARIS

Hi !
Thank a lot for your answer !!

I followed all the steps, but when I have an error message saying for the Add Data Row :
“Object reference not set to an instance of an object.”

Any ideas ?

may i know what was mentioned in the arrayrow property and in the datatable
if possible can i have a screenshot of the property panel of add datarow activity


Wow !!

Now it’s working my bad !

Thanks !

1 Like

Cheers @Pierre_PARIS