Finding the similar columns between two different sheets

I am trying to find the similar columns between two different sheets and put it in a new table with this expression but it shows me an error in the assign activity which is "no data rows "

Hi @Rawan_Ghurab

Check out this tutorial

Thank you for your response but what about my case? I did not understand

Hi @Rawan_Ghurab

Can you share the sample input and expected output?

How about this expression?

DT_Final = DT_2.AsEnumerable.Where(Function(r) not DT_1.AsEnumerable.Any(Function(r2) r2("Phone").ToString=r("Phone Number").ToString)).CopyToDataTable.DefaultView.ToTable(False,{"Date","Phone Number","Currency"})

You can check out this thread

Regards
Gokul

Thank you for your response , But I don’t want to remove the duplicate I want to save the similar columns in new data table

It will not remove the duplicate, I have share this thread for the reference

??? @Rawan_Ghurab

This is the input these two sheets:


and this is the output after override this column must be removed because its not exist in the other sheet

Hi @Rawan_Ghurab

Try with this following expression?

Dt2.AsEnumerable.Where(Function(r) DT1.AsEnumerable.Any(Function(r2) r2("Ship Mode").ToString=r("Ship Mode").ToString And r2("Profit").ToString=r("Profit").ToString And  r2("Unit Price").ToString=r("Unit Price").ToString And r2("Shipping Cost").ToString=r("Shipping Cost").ToString And r2("Customer Name").ToString=r("Customer Name").ToString)).CopyToDataTable

Note : Update the column name as per the input excel files.

Regards
Gokul

what is r2 ?

Here r2 is the function variable that declare for Dt1

it gives me this error " Assign: Column ‘Shipping Cost’ does not belong to table DataTable."

HI @Rawan_Ghurab

Whether Shipping Cost column is available in the data table?

The error saying like we don’t have Shipping Cost Column. So update the column name

yes it is available you can see it above

It is available in both the excel file? @Rawan_Ghurab

no only on one excel

That’s why I told you I want to have the similar columns only and put it in a new data table

Duplicate Topic : How to compare two different columns headers and if it similar save the whole column in new data table

Hi @Rawan_Ghurab

Check out this video link

Check out this thread

Regards
Gokul

How to compare two different columns headers from different sheets and if it similar save the whole column in new data table

i have dt1 and dt2 , i want to check all the headers of dt1 if it available in d2 , once its founded the I will create new dt3 and put the dt1 column there