How to do look up in linq query for two sheets

I have one sheet as (sheet4temp) and another sheet as (combo) in this both sheets I have asin column and I want to lookup for asin column if they match I want to write the result in the c column of sheet4temp. so how to write a LINQ query for this?

Hi @sathish_Kumar6

dt1.AsEnumerable.Where(Function(a) dt2.AsEnumerable.Any(Function(b) b(“Colunname”).ToString=a(“columname”).ToString)).CopyToDataTable

with this im getting whole sheet of “sheet4temp”

so i have like this

in sheet4temp I have

orderno asin
1 mat1
2 mat2
3 mat3

in combo sheet I have

combo mat3
combo mat2
combo mat1

so need to do lookup for both sheets and matched values should be written beside to asin column of sheet4temp


Use a join activity followed by filter to remove the unwanted columns after join

For you if the top table is considered as right table and bottom is considered as left then you need to perform left join so that you get matched and unmatched rows as well

If you need other way then use as below

Add a data column for order no

Then inside invoke code use as below

LeftDt.AsEnumerable.ToList.ForEach(sub(r) r("OrderId") = If(rightdt.AsEnumerable.Where(function(x) x("asin").ToString.Equals(r("asin").ToString)).Count>0,rightdt.AsEnumerable.Where(function(x) x("asin").ToString.Equals(r("asin").ToString))(0)("OrderId").ToString,""))


This is called a join. It’s a standard database operation. Use the Join Data Table activity.

1 Like

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