Merge tables when row order different

Hi Team,

I need to merge 2 different table based on one particular column - GEID . The 2 excel table is given below

Table 1:

image

Table 2:

image

If you could observe the order of rows are different when you try to match with “GEID” column apart from Row 1 . I use “Join Data Tables” to merge table to get expected output

image

But output I received was something like this

image

What i found was only first row is merged remain all rows are not merged but added as new row, since I used “Full” join type.

Could you please suggest how can i join when row order is different

Merge Data Table is not for joining rows. It’s for simply taking two datatables and concatenating them into one.

Assuming you have DT1 and DT2 above, you’ll need to loop through DT1 and using Select, manually create combined rows into DT3 based on matching GEID.

1 Like

Hi @Deeipauk !
Just try to use the Inner join, and I think you will get your expected output :wink:
image
Let us know if it’s not what you want !

1 Like

@Deeipauk - I have attached for Merging DT xaml file for your reference.

DT.zip (116.2 KB)

Happy Learning :slightly_smiling_face:

1 Like

we do face some outputs in case of the values from join columns are not matching. Escpecially when data comes from Excel a space on the end can provoke such output.

We would recommend to have a quick check in excel if this is the case e.g. for the second row (not doing the matching) and to implement some cleansing on the data.

In case of only the result of inner join is needed we can also do it with a LINQ already implementing such trimin / cleansing.

1 Like

Thanks for all your responses. @Hiba_B - I tried inner join that also didn’t work. @saijagadesh06 - Thanks for sharing the code snippet
Comment given by @postwick is right, merge will just concatenate, so always row 1 - row 1 comparison it will do.

I resolved it by a simple logic - Sort both DT using “GEID” then merge :slight_smile:
asc or desc in any order, both DT will have GEID in same order then merge is possible.

Another important point as part of my learning, “GEID” in both excel should be in same format - “General” or “Text” (Prefer - Text)