Compare 2 tables row by row

Hey!
I’m trying to compare two tables of only one column, but I want to compare row 1 of the first table only with row 1 of the second table, the second row of table 1 with the second row of table 2 and so on, I have 20 rows, I can do it with a for each row? this way I compare the first row with all the fields of the table.
greetings!

Hi @Juan_Antonio_Goncalves_Ro

Could you share sample data for both datatables.

Regards

Hi @Juan_Antonio_Goncalves_Ro

Use 2 for each row in datatable activities to iterate
Inside for each
USe an if condition
Currentrowdatatable1(“columnname”)=Currentrowdatatable2(“columnname”)

Hope it helps!!

Hi @Juan_Antonio_Goncalves_Ro

Try below code

Test1.zip (2.2 KB)

Hope it will helps you :slight_smile:
Cheers!!

Yeah!
I have it done this way, but this way it uses the first varlor of the first table and compares it with the whole second table.
I need something like this:


this is my sequence:

Cheers!

Hi @Juan_Antonio_Goncalves_Ro

After comparing what you want to do?
You want to write the selected rows in a other datatable.
Or you want to get the values of datatable1 in an array.

Could you be more elaborate your query…

yes, I want to compare these data, write them in an excel file and if they are the same, put that they match or not.

Hi

Let your DTs be known as:
Dt1 and Dt2

Step 1 Insert a new column for Dt1 called “Match”

Step 2 a for each row for Dt1

Step 3 insert an if Condition,

Condition:
currentRow(0).ToString.ToUpper.Trim = dt2.Rows(dt1.rows.indexof(CurrentRow))(0).ToString.ToUpper.Trim

Then Branch:
Insert assign
Left:
Row(“Match”)
Right:
“TRUE”

Else Branch:
Insert assign
Left:
Row(“Match”)
Right:
“FALSE”

Hopefully this works/helps,

Cheers

Steve

Follow the below process -
→ Use read range workbook activity to read the excel1 and store in a datatable called dt1.
→ Use another read range workbook activity to read the excel1 and store in a datatable called dt1.
→ Insert Build datatable activity to create a new datatable and add two column to it Column A and status, create a datatable variable called Output_dt for the Build datatable activity as below.
image
→ Use the assign activity to check the condition by using LINQ Expression

- Assign -> Output_dt = (
                         From a In dt1
                         Join b In dt2
                         On a(0).toString Equals b(0).toString
                         Select Output_dt.Rows.Add({a(0),"Matched"})
                           ).copytodatatable

→ Use write range workbook activity to write the Output_dt variable to the excel file, Check the add headers option in the properties.

Check the below workflow for better understanding,

Hope it helps!!