Filtering repeating values in excel join datatable

@gokul1904
we do feel that following approach is matching better to the case as it less blackbox and can better be inspected e.g. during debugging

Variables:

Flow - Segmenting:

valCheck = dtData.AsEnumerable.Skip(mySkip).First()("Col1").toString.ToUpper.Trim
ExtractSegments = ExtractSegments.Append(dtData.AsEnumerable.Skip(mySkip).TakeWhile(Function (x) x("Col1").toString.ToUpper.Trim.Equals(valCheck)).toList).ToList
mySkip = ExtractSegments.SelectMany(Function (x) x).Count

in a do while

  • retrieve the check value
  • skip or start by 0
  • extract the subsequent Rows, where the Col1 value is equal to the check Value
  • Calculate the new Skip

Flow - Deduplication & Result Datatatable Building
grafik

Result = ExtractSegments.Where(Function (x) x.Count > 1).Select(Function (x) x.Last()).toList

Sample Date (testing also the no duplicate case)
grafik

Part result:
grafik

Find starter help here:
TakeWhile_MakeSeriesGroup_TakeLastFromDuplicate.xaml (12.2 KB)

1 Like