Comparing two data tables

[DataRowComparer] maybe more simple.
Here is my code.
comparing-two-datatables.zip (10.0 KB)

3 Likes

@lainh hi,

you have to do it with a for each row inside of another for each row.

For example:

Call the rows of the first for each → row
Call the rows of the second for each → line

Then, you can check the values using:
if(row(“The name of your column”).toString <> line(“The name of your column”).toString)

→ writeLine : “We have a dismatch”

I hope it can help you, I guess it is easy to understand.

Bests,
Pablo

5 Likes

Hi @Pablo_Sanchez

I did what you said in the [invoke code] activity with different method.
You can check the xaml flle on [invoke code].

My way is

  1. use [DataRowComparer] to found if the tow rows are different
  2. to compare the columns of the datarow above to find which pair of cells is unmatched in loop.
1 Like

@lainh I’m sorry… I don’t have so much time now… so much work to do :disappointed_relieved:

If I have time I will check the .xaml, I hope you will get help before as I will be able to check it

Bests,
Pablo

2 Likes

@Pablo_Sanchez
What I said is before your post#7 , I have already did what I said in post#9

Hi Pablo,
Thanks for your reply!
I have used the same logic in my work flow.

2 Likes

Hi @Ananthu…Could you please share your solution, i have a similar requirement.

Thanks again
Gaurav

Hi Gaurav,
I have attached the comparison logic workflow. Kindly let me know if you got struck somewhere.

Thanks and regards,
Ananthu
Comparison logic.xaml (22.3 KB)

5 Likes

@Ananthu Thank you so much, i am reviewing it now.

Thanks again
Gaurav

1 Like

Dear @Ananthu
I tried to use your Comparison logic.xaml file.However, when process comes to Assign counter=counter+1 I got message:
Object reference not set to an instance of an object. This error usually occurs using a variable with not set value (not initialized).

I will appreciate if you can explain how to fix it.
test1.xlsx (16.6 KB)
DD.xaml (24.1 KB)

In the finale I want to get 3 rows on the sheet C which contains differences…

Thank you for the advice and help!

2 Likes

Hi @Aggi ,
Just initialize the counter variable with 0. That should resolve your issue.
Kindly let me know if you face any other issues.

Thanks and regards,
Ananthu

1 Like

Dear @Ananthu, thank you. it is working!

1 Like

Dear @Ananthu,

would you be so kind to explain me some problem with code. I use it and I got mistake…it is count every second column of the table (not each) AExample.xaml (31.8 KB)
test1.xlsx (17.4 KB)

Hi @Aggi,
Will look into it tonight. I’m in office.

Thanks and regards,
Ananthu

1 Like

Hi @Aggi,
The problem with your test1 excel sheet is that it haven’t got any unique element to map across sheets for comparison.

In the attached workflow, I have used the row index as unique element and did the comparison. Kindly let me know if you face any issues.
AExample.xaml (34.9 KB)

Thanks and regards,
Ananthu

1 Like

Hi @Ananthu,
thank you for help. I understand now everything clear -)
Have a nice weekend.
Agata

1 Like

Have a great weekend!

Hi Ananthu,

I am stuck in a similar problem…

I have two data tables, one contains the names, another datatable contains another set of names, i just need to check if the name in dt1 is present in dt2.

can you please help me?EXCELanasys.xaml (35.2 KB)

Hi shreyaank,
Ya sure! I will send you the workflow by tomorrow…

Thanks and regards,
Ananthu

Hi @shreyaank,
I have verified your work flow. You have to initialize the variable i to 0. If you still have issues, kindly send me the excel sheet so that I could verify.

Thanks and regards,
Ananthu