@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:
retrieving the max length for the longest group:
Preparing the result datatable columnstructure:
Build datatable with first column (ColName: Key), then we do add the other columns:
Finaly we use following LINQ for populating the target DataTable:
- 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: