Rows are swapped after Join Datatable operation

Hello everyone,

I have joined the following two tables as follows.

image

But after the join operation, the data changes place.

How can I fix this.

Thanks!

Hi @MrKezay

May I know the output that you require?

Thanks

1 Like

I want it like the first one.

Thanks

@MrKezay

Correct me if I am wrong

your dt1:

your dt2:

image

your required output

sorry just trying to understand I can see your dt1 is same as output?

1 Like

Sorry, I couldn’t express myself.

I want the result like the first datatable.

Order of data in first table

Alperen KEZAY
Zeynep KEZAY
Ahmet KEZAY

But output like this

Alperen KEZAY
Ahmet KEZAY
Zeynep KEZAY.

I don’t want the order of the data to change.

Hi,

Can you try to order the result using the following expression?

out_JoinDt.AsEnumerable.OrderBy(Function(r) Array.IndexOf( dataListesiDt.AsEnumerable.Select(Function(x) x("EmployeeName").ToString).ToArray(), r("EmployeeName").ToString)).CopyToDataTable()

Regards,

1 Like

@MrKezay
the Join DataTable can have a result where the row orders are changed e.g. compared to dt1.
Lets assume we can rely to the email for identifying a particular row, then we can reorder the the join result by following:

Assign activity
left side: dtJoinOrdered | DataTable
Righ side:

(From d in out_JoinDT.AsEnumerable
let e = d(“EmployeeAdress”).toString
let i = dataListesiDT.AsEnumerable.toList.FindIndex(Function (x) x(EmployeeAdress).toString.Equals(e))
Order by i
Select d).CopyToDataTable

1 Like

Thank you so much @ppr and @Yoichi

Both expressions are correct. Sorry Yoichi, Peter’s solution is more explanatory I’m flagging his solution.

Thank you again, I have a lot to learn from you.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.