How to compare 2 columns from 2 datatable and if any value matches, extract another column value of the matched row

How to compare 2 columns from 2 datatable and if any value matches, extract another column value of the matched row

Hi @shilpashree.mohanty ,

use below query

(From p in dt.Select() where( From q in dt1.Select() where q("ColumnName1").Equals(p("ColumnName")) Select q)).ToArray.CopyToDataTable()

Regards,
Arivu

how can i store the value in a variable?

as you mentioned you have 2 datatable consider dt is first table & dt1 is second table.

input is in excel file please use read range activity to get the data as datatable
Regards,
Arivu

@arivu
no my question is
i read dt1 and dt2
i need to compare columnA of dt1 to any matching values in columnB of dt2 (both are differently named column)
now, if there is a match, extract the corresponding value of columnC from dt2

matchedRows = From row1 In dt1.AsEnumerable()
From row2 In dt2.AsEnumerable()
Where row1(“columnA”).ToString() = row2(“columnB”).ToString()
Select row2(“columnC”).ToString()

this is in invoke code?

Hi @shilpashree.mohanty,

Use assign activity

getting this error,

@arivu96 , can you please help

Can you share the query

string var = from ro1 in dt_FilteredWires.AsEnumerable() from row2 in dt_Mapping.AsEnumerable() where row1(“Rem”).ToString() = row2(“Medea Upload”).ToString() select row2(“TRAX payor”).ToString()

string var = (from ro1 in dt_FilteredWires.Select() where (from row2 in dt_Mapping.Select() where row1("Rem").ToString().equals(row2("Medea Upload").ToString()) select row2) .CopyToDataTable().First().Item("TRAX payor").ToString()

Try above syntax

@arivu96
Getting this :frowning:

Convert.ToString((From row1 In dt_FilteredWires.Select() Where(From row2 In dt_Mapping.Select() Where row1("Rem").ToString().Equals(row2("Medea Upload").ToString()) Select row2).CopyToDataTable()).Rows(0)("TRAX payor"))

@arivu96

@arivu96
Can you help me here?

Could you share the sample snipe here, will share the flow with you

Its inside VDI, wont be able to help

use assign activity… or if you want invode code means, you have to use another syntax