I want to have two rows for each assignee in the attached excel file.
I can get the distinct value by using the below code but i need two values for each distinct value.
DT = ((From LineNo In DT.DefaultView.ToTable(True,“Assignee”).Select().ToList() Select (From row In DT.Select Where row(“Assignee”).ToString=LineNo(“Assignee”).ToString Select row).ToList(0)).ToList()).CopyToDatatable()
If you are sure that there are two rows available for each assignee,
Just use similar query to load the second row -
DT1 = ((From LineNo In DT.DefaultView.ToTable(True,“Assignee”).Select().ToList() Select (From row In DT.Select Where row(“Assignee”).ToString=LineNo(“Assignee”).ToString Select row).ToList(1)).ToList()).CopyToDatatable()
Change in the query - ToList(1) //loading the second matched value
First duplicate the DT to another data table. For example DTCopy = DT.
Without cloning the DTs, the queries won’t work. Because after first query, there will be only one Assignee row will present and the second query will return error.
DTCopy = DT
DT = ((From LineNo In DT.DefaultView.ToTable(True,“Assignee”).Select().ToList() Select (From row In DT.Select Where row(“Assignee”).ToString=LineNo(“Assignee”).ToString Select row).ToList(0)).ToList()).CopyToDatatable()
DT1 = ((From LineNo In DTCopy.DefaultView.ToTable(True,“Assignee”).Select().ToList() Select (From row In DTCopy.Select Where row(“Assignee”).ToString=LineNo(“Assignee”).ToString Select row).ToList(1)).ToList()).CopyToDatatable()
hello @Onkar_Nath_Sharma
email ids in attached excel file looks valid to me…
if this is the case… kindly remove the attachment as this is a public forum… and email spammers might get hands on it…