Compare 2 datatables single columns and order them to be identical

Hey everyone,

I have 2 datatables, dt1 and dt2.

dt1:
image

dt2:
image

now what I want to accomplish is, I want to compare these datatables “number” and “integer” columns, if they are identical I want to return a boolean value as true.( for example it should return true on top example)

And if it returns true I want to reorder dt1’s rows as dt2, so:
image this will become image

I appreciate every help thank you,

Hi,

This might not be the nicest way, but still a way:
var newDt1 = dt1.clone()
Loop thru dt2:
Filter data table(dt1 as input): Column:“number” = row.item(“integer”).tostring
IF: output filter_output_dt.rows.count = 1
add datarow to newDt1
Else:
DataTables isnot same

Sorry for messy explanation but I am writing from phone

Thank you.

I get it somehow and I made the code but I get Add Data Row: This row already belongs to another table.

any reason for this error?

Try use row.ItemArray in “ArrayRow” instead.

image

this returns the the table I dont want to sort with the headers of the table I want to sort :slight_smile: even writing this sentence was hard.

What I before used as input was filteredDT.rows(0) in datarows section. Which is contains the row I need actualy, so I collabrated with your solution, outDT.Rows(0).itemArray is working :slight_smile:

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