TransPose DataTable

Dear all,
I would like to check if it is possible to transpose a datatable with Linq.
Most guide shows from a tabular format (B) to (A) but not the other way round.

Appreciate the community help and thank you in advance!

Sample Data
New Microsoft Excel Worksheet.xlsx (9.4 KB)

A. Raw Data

Row Number Sales Purchase Derivative Entrust Ship Sales

B. Expected Result

Row Number Commodity Value
1 Sales AOK
1 Purchase
1 Derivative
1 Entrust CC
1 Ship Sales


One of more options:

  • Build DataTable Activity - dtResult, Configured 3 Columns: RowNumber, Commodity, Value
  • Assign activity
    dtResult =
(From d in dtDataOrigVar.AsEnumerable
From i in Enumerable.Range(0, d.Table.Columns.Count).Skip(1)
Let ra = new Object(){d(0), d.Table.Columns(i).ColumnName, d(i)}
Select r = dtResult.Rows.Add(ra)).CopyToDataTable

Hi @Md_Hidayat

Please check on this

Hope this helps!!