Dynamically Adding Columns to DataTable Using LINQ

I have a DataTable as shown below:

image
And this is the output I want:
image

If the names and columns can be ordered(A-Z), that would be great as well.
I know how to achieve the output, but not with LINQ, so I was hoping someone could provide some pointers on this.

Help of any kind is most appreciated, Thanks in advance!

Kind Regards,
Ashwin A.K

@ashwin.ashok
we can interpretate the case as a certain kind of transponation.

Lets assume following sample input:
grafik

we prepare the target Datacolumn structre by a build datatable for the name column
and do add the ordered country columns
grafik
with one go we also do create an array with the country names - newColNames

Finaly we following LINQ dtData will be transposed accordingly the case requirement (flag with *)

grafik

Result:
grafik

Find starter help here:
Transponation_LINQ_NameCountry.xaml (9.3 KB)

2 Likes

Brilliant as always!
Thank you so much.

Kind Regards,
Ashwin A.K

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