Need help with Linq Query With Compare data in Excel with data base

Below image is DataBase Data

Below image is Input Data
Screenshot 2024-03-22 143903

How to match Input columns --CompanyCode ,Id, Date is variable with database excel columns–CompanyCode ,Id,Date

If Match found ,need to check Statement sent Column in data base with yes value if it is true need to update reference Column in dataBase in Input Excel
Output
Screenshot 2024-03-22 160723

output CompanyCode 1234 ,Id 56789, Date 30.02.2024 that should match and again need to check Database StatementSent Column if found Yes need to update Reference in input excel (ReferenceNumber 123

need help with Linq query
@Yoichi @Gokul001

Need help

@srujana13a5

you can use this in assign

dt = dt.AsEnumerable.Where(function(x) dtDatabase.AsEnumerable.Any(function(y) y("ID").ToString.Equals(x("ID").ToString) AndAlso y("CompanyCode").ToString.Equals(x("CompanyCode").ToString) AndAlso y("Statement").ToString.Equals("Yes"))).CopyToDataTable

cheers

HI,

Can you clarify which columns should be compared? And also can you share input and expected output as file?

Regards,

Yes sure
Sample.xlsx (9.2 KB)
here date is last Date in Last month

Here is the solution,

LinQ:
(From row In dt_Database
Join main In dt_InputTable
On row(“CompanyCode”).ToString Equals main(“CompanyCode”).ToString And row(“ID”).ToString Equals main(“ID”).ToString
Let ReferenceNo = If(row(“StatementSent”).ToString.Trim.ToLower.Contains(“yes”),row(“ReferenceNumber”).ToString.Trim,“”)
Select dt_Output.Rows.Add({row(“CompanyCode”).ToString,row(“ID”).ToString,ReferenceNo,row(“StatementSent”).ToString})
).CopyToDatatable

I have also attached .xaml for your reference.

Thankyou.
Compare Excel Data Sequence.xaml (8.9 KB)

Thank very much for you reply but Date also need to match that is last date in laste month variable
so that is not present in input sheet

Can you please share the expected output format you need (Screenshot)?

yes I put Screen shot

Can you please help

Is it correct?

Database Table:
DatabaseTable

Input Table:
InputTable

Output Table:
OutputTable

I have matched Last date of previous month if it is not correct and StatementSent should also be “No” then it will leave reference column as blank.

Data base date colomn also need to compare but that is not the column in input excel that is last date in last month variable

Please help with that

can you share code please