Changing of data base format

Hi,

I have the table
image
I would like to receive this format of data:
image
Any suggestions?

@Krzysztof
lets build an empty datatable with the target structure:
grafik

let retrieve the company column names for a later lookup:
grafik

lets do the detransponation with following LINQ:

(From d In dtData.AsEnumerable
Let mr = d.ItemArray.Skip(1).Select (Function (x, i) New Object(){d(0),Companies(i), x }).ToArray
From ra In mr
Order By ra(1).toString
Select dtResult.Rows.Add(ra)).CopyToDataTable

Line1 - iterate over the data - refernce looped row with r
Line2 - create the rowArray for the target rows:

  • skip(1) - omit name column
  • iterate over the remaining items of ItemArray and create an ObjectArray - return all as array

Line3 - iterate over the result of mr
Line4 - order it by the company name
Line5 - add the item to the target datatable

Result:
grafik

find starter help done with a LINQ here:
Datatable_DeTranspose.xaml (9.8 KB)

1 Like

How to add variable type String? I have never used it so far:(

on variable panel:
grafik
2nd step:
grafik

1 Like

IT WORKS! THANKS A LOT!!!

Perfect, it is working
take your time for doing the final testing. May we ask you to mark afterwards the solving post as solution. So others can benefit from it, when a similar case is researched.
Thanks

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