(From a In dtSheet1.AsEnumerable() Join b In dtSheet2.AsEnumerable() On a(âWeek Dayâ).ToString Equals b(âWeek Dayâ).ToString Select dtSheet3.LoadDataRow (new Object() { a.Field(Of String)(âWeek Dayâ), b.Field(Of String)(âNAMEâ),a.Field(Of String)(âQtyâ), a.Field(Of String)(âPart Numberâ), },False)).CopyToDataTable
(From a In DemandDT.AsEnumerable() Join b In WeekFormatDT.AsEnumerable()
On a(âWeek Dayâ).tostring Equals b(âWeek Dayâ).tostring
Select dtSheet3.LoadDataRow (New Object() { a.Field(Of String)(âWeek Dayâ), b.Field(Of String)(âNAMEâ), a.Field(Of String)(âQtyâ), a.Field(Of String)(âPart Numberâ), },False)).copyToDataTable
Kindly note:
It can happen that read range will force the dates internally to different formats and causes that dtTemp creation will fail. In such case always check within a debug what are the values in dt1, dt2 and force or adopt the values before joining to dtTemp.
This behaviour is not a bug in LINQ, it is a behaviour of the result from Read Range
Good Day.
I ran the .xaml file with my actual data and it is giving the following error.
Add Data Column: A column named âW202102â already belongs to this DataTable. I believe the sample data was not enough. My apologies for that.ScrapedData.xlsx (32.2 KB)
I am attaching the actual data for your reference.
(From d In dtTemp.AsEnumerable
Let w = CInt(Regex.Match(d("Week Format").toString,"\d+").toString)
Order By w
Select d("Week Format").toString.Trim).Distinct().toArray
I tried your solution too. I am getting the following error. Please use the ScrapedData.xlsx for further testing which was posted after the initial post.