# Transpose the datatable

**URL:** <https://forum.uipath.com/t/transpose-the-datatable/746550>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, system, activities\
**Created:** [June 10, 2024, 7:12am UTC](https://forum.uipath.com/t/transpose-the-datatable/746550 "2024-06-10T07:12:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![SunnyJha](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sunnyjha/32/401187_2.png) [@SunnyJha](https://forum.uipath.com/u/SunnyJha)\
**Post date:** [June 10, 2024, 7:12am UTC](https://forum.uipath.com/t/transpose-the-datatable/746550/1 "2024-06-10T07:12:26Z")

</div>

Hi, i have a datatable dt which needs to transposed to do further operation.

input dt:-

 ![image](https://global.discourse-cdn.com/uipath/original/4X/a/1/4/a14c56b8715c6c0870b79a41d93e27ea4a6232ae.png)

output dt:-

 ![image](https://global.discourse-cdn.com/uipath/original/4X/4/b/c/4bcfe8575e4b6d40634417169d4a1e357d88d3c6.png)

As you can see in the transpose datatable I dont need the “Mapping” column and the column headers from the input dt.

@Yoichi

---

<div class="post-metadata">

**Author:** ![vrdabberu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vrdabberu/32/484365_2.png) [@vrdabberu](https://forum.uipath.com/u/vrdabberu)\
**Post date:** [June 10, 2024, 7:16am UTC](https://forum.uipath.com/t/transpose-the-datatable/746550/3 "2024-06-10T07:16:14Z")

</div>

HI @SunnyJha

Check the below thread:

> [@How to transpose datatable?](https://forum.uipath.com/t/how-to-transpose-datatable/741886/3):
>
> @SunnyJha You can follow the steps Delete the first column as you dont need usign delete data row Now use generate datatable activity and pass the string as String.Join(",",dt.AsEnumerable.Select(function(x) x(0).ToString)) and select comma as row separator and check the header box Delete the column which you want as headers also the second one Now use for loop with loop on all columns dt.Columns Now inside use add data row and in the arrayrow property pass String.Join(",",dt.AsEnumerable.Sel…

Regards

---

<div class="post-metadata">

**Author:** ![SunnyJha](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sunnyjha/32/401187_2.png) [@SunnyJha](https://forum.uipath.com/u/SunnyJha)\
**Post date:** [June 10, 2024, 7:26am UTC](https://forum.uipath.com/t/transpose-the-datatable/746550/4 "2024-06-10T07:26:48Z")

</div>

I had tried this but wasn’t able to understand.

---

<div class="post-metadata">

**Author:** ![hammad\_rafiq](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hammad_rafiq/32/482275_2.png) [@hammad\_rafiq](https://forum.uipath.com/u/hammad_rafiq)\
**Post date:** [June 10, 2024, 7:42am UTC](https://forum.uipath.com/t/transpose-the-datatable/746550/5 "2024-06-10T07:42:38Z")

</div>

Hey @SunnyJha

Try This.

 ![image](https://global.discourse-cdn.com/uipath/original/4X/8/d/7/8d7b541ae0d592c3f54f8c6397fbe317bb2156e5.png)

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [June 10, 2024, 8:12am UTC](https://forum.uipath.com/t/transpose-the-datatable/746550/6 "2024-06-10T08:12:25Z")

</div>

@SunnyJha  
Give a try at this starter help

Variables:

 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/4/a/5/4a5142deb3206c61e0c25e64945da41ed959fb31.png)

Flow:  
 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/4/b/d/4bd2103c43b71df1383d62b5d4cdfc53234cd7a0.png)

`kwr = dtData.DefaultView.ToTable(False, {"Keyword"})`  
Add DataColumn Details:  
 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/4/8/e/48e045b9e3809830080e4f47c2318ef5b781b374.png)

```auto
dtTransposed = 
(From i In Enumerable.Range(0, dtData.Columns.Count).Skip(2) 
Let ra = dtData.AsEnumerable.Select(Function (x) x(i)).ToArray
Select r = dtTransposed.Rows.Add(ra)).CopyToDataTable

```

---

<div class="post-metadata">

**Author:** ![vrdabberu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vrdabberu/32/484365_2.png) [@vrdabberu](https://forum.uipath.com/u/vrdabberu)\
**Post date:** [June 10, 2024, 8:19am UTC](https://forum.uipath.com/t/transpose-the-datatable/746550/7 "2024-06-10T08:19:39Z")

</div>

HI @SunnyJha

Xaml:  
[Sequence51.xaml](https://forum.uipath.com/uploads/short-url/2olzRXD4SUaKfnpXTH1EKA8qbxj.xaml) (8.6 KB)

Input:  
[Input 7.xlsx](https://forum.uipath.com/uploads/short-url/Argpq30WcNfVa5cibVzYDcQTo8D.xlsx) (9.0 KB)

Screenshot:

 ![image (1)](https://global.discourse-cdn.com/uipath/original/4X/b/5/b/b5be650d33f6bb231758eeaf15380bca219ca8de.png)

Regards

---

<div class="post-metadata">

**Author:** ![vrdabberu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vrdabberu/32/484365_2.png) [@vrdabberu](https://forum.uipath.com/u/vrdabberu)\
**Post date:** [June 10, 2024, 8:35am UTC](https://forum.uipath.com/t/transpose-the-datatable/746550/8 "2024-06-10T08:35:30Z")

</div>

Hi @SunnyJha

You can use the below workflow also:

Sequence:  
[Sequence51.xaml](https://forum.uipath.com/uploads/short-url/zuF0U2vBtguyTlqHSOzf2T0vcml.xaml) (10.9 KB)

Input:  
[Input 7.xlsx](https://forum.uipath.com/uploads/short-url/vyPzDYQuqLMSuKRBAHMBD9fJqHl.xlsx) (9.5 KB)

Screenshot:

 ![image](https://global.discourse-cdn.com/uipath/original/4X/5/2/e/52e6c391a6b1f0b974fb5e584f3b9f6f16cb274a.png)

Regards

---

<div class="post-metadata">

**Author:** ![SunnyJha](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sunnyjha/32/401187_2.png) [@SunnyJha](https://forum.uipath.com/u/SunnyJha)\
**Post date:** [June 10, 2024, 11:31am UTC](https://forum.uipath.com/t/transpose-the-datatable/746550/9 "2024-06-10T11:31:53Z")

</div>

Thanks Petr. I made some modifications on your logic and its working as per my need. Thanks again!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [June 13, 2024, 11:32am UTC](https://forum.uipath.com/t/transpose-the-datatable/746550/10 "2024-06-13T11:32:39Z")

</div>

Closed on June 13, 2024, 11:32am UTC

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