Column Transpose with Condition on its Cells' Values

@hsendel
we can do it dynamicly with the help of groupBy, dictionary and LINQ

Variables:

Grouping the data by the the first two letters into a dictionary:
grafik

retrieving the max length for the longest group:
grafik

Preparing the result datatable columnstructure:
grafik

Build datatable with first column (ColName: Key), then we do add the other columns:
grafik

Finaly we use following LINQ for populating the target DataTable:
grafik

  • LINQ iterates over the GroupDictionary
  • Fills up missing columns by empty values
  • Concats exisitng values with filled up values (pra)
  • Adds the key info to the rowArray (ra)
  • uses the rowarray to add the datarow to dtResult

Input (Similar to your Excel), GroupDictionary and dtResult:

Find starter help here:
GroupBy_1Col_TransposeMembers.xaml (11.8 KB)

Find some further help also here:

3 Likes