Duplicate value handling in excel

(From d In dtData.AsEnumerable
Group d By k1=d(2).toString.Trim, k2=Math.Abs(CDbl(d(3).toString.Trim)) Into grp=Group
Select grp.toList).toList

image
this is the input data

can anyone explain this code to me in brief?

Hi @Tanzill_Ahsan,

From what I understand, for removing duplicates in excel, you are grouping by two keys (k1 and k2). My understanding is:

  • With “From d In dtData.AsEnumerable” you iterate over dtData.
  • With “Group d By k1=d(2).toString.Trim, k2=Math.Abs(CDbl(d(3).toString.Trim)) Into grp=Group” you group the data by the specified key (k1 and k2) value and then reference the group with grp. d(2) and d(3) are the indexes of the columns you are filtering by, I believe. The meaning of each function contained in the keys can be found in internet.
  • With “Select grp.toList).toList” you select from the group grp (which is a collection) each individual item.
1 Like

@ydimitrova thank you

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