How to compare columns from two different data tables?

I have two data tables Dt1 and Dt2 and their column names are not same but some of their values might be same…
I want to compare Colmn1 values of DT1 with Column1 values of DT2 and when it finds a match in a certain row it should enter that row values (both from DT1 and DT2) in to another datatable DT3

Hello there! I am new to UiPath and decided to try this as a practice exercise for myself. I used Excel because I don’t have access to a database, but the logic should be the same.

What I found that worked for me was as follows:

For each current row in DT1 write cell to Scratchpad A1
For each current row in DT2 write cell to Scratchpad B1
If Scratchpad A1 = Scratchpad B1 write cell to DT3 (specify cell) and check box to auto increment row

I hope this helps.

1 Like

Thanks for your suggestion…
Can you please elaborate a bit about scratch pad as I’m also a beginner…
And will this approach help me in joining columns from both datatable in to third one?

My apologies, Sami.

It looks like the Project Notebook Excel file which has the scratchpad sheet is not available in Studio like it is in StudioX. Project Notebook is a tool that you can use in StudioX to help with formatting data like file names, dates, text and such. It has a scratchpad sheet that you can write cells to and then use that text in other activities. You can switch your profile in Studio over to StudioX and gain access to it if you want.

If you have to keep your project in Studio, you could create an excel and add it to your project. It would not need to have anything in it–just a new excel with no data. Then you just say to enter the DT1 cell value to A1 in your empty Excel and your DT2 cell value in to B1 in your Excel. Your IF activity would then compare the values from A1 and B1 in your Excel and you can set the condition to A1=B1. If they are equal, you add an activity to write the cell value (from either cell because they are an exact match) to the specified cell in DT3.

Hello @Sami_Rajput

Are you trying to compare multiple datatables and to find similar and disimilar rows?

If yes, you can watch the below video. After getting the tables you can merge to a new datatable.

1 Like

In my case, I want to compare only the first Column from both data tables and if there is a match then I want to merge that row of both data tables

Hi @Sami_Rajput ,

Maybe you could provide a Sample input of your case, and it’s Expected Output. So that we can understand what logic that we would need to apply.

Note that Merging/Combining of two datatables into one requires the Schema to be Same or a Mapping between the First Datatable Columns to the Second Datatable columns needs to be provided.