# Transpose with grouping

**URL:** <https://community.easymorph.com/t/transpose-with-grouping/1716>\
**Category:** General Q&A\
**Created:** [March 5, 2020, 8:59pm UTC](https://community.easymorph.com/t/transpose-with-grouping/1716 "2020-03-05T20:59:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raskarov](https://community.easymorph.com/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@raskarov](https://community.easymorph.com/u/raskarov)\
**Post date:** [March 5, 2020, 8:59pm UTC](https://community.easymorph.com/t/transpose-with-grouping/1716/1 "2020-03-05T20:59:41Z")

</div>

Hi, I can't figure out how to perform the following conversion. (Tried Pivot, Unpivot, Group, but nothing seems to work...)

Source data:

 ![image](https://community.easymorph.com/uploads/default/original/2X/4/44e3ae35b39e097b01f4c08a2543498f882a6d62.png)

I need to group by seller and buyer and set columns as rows, as follows:

 ![image](https://community.easymorph.com/uploads/default/original/2X/4/401707464e5a1064a355f5341787aee1cfbe1896.png)

If this example is too complex, simplified version would just not have 2nd item. So, if I can solve this for one item, I think I can do the rest with derived tables and then union them back.

Simplified example:  
Source:

 ![image](https://community.easymorph.com/uploads/default/original/2X/9/9eb4498e55fa98eb67b3ccf06b732ef2ef3096f6.png)  
Result:  
 ![image](https://community.easymorph.com/uploads/default/original/2X/0/055d06dcc2d5296956b6fc93a15a2d46ee979b06.png)

Examples excel attached. All pointers and suggestions are appreciated. [Book1.xlsx](https://community.easymorph.com/uploads/short-url/9KS8BvTW91Eq6a28maWGIwxdpIB.xlsx) (11.3 KB)

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [March 11, 2020, 9:22pm UTC](https://community.easymorph.com/t/transpose-with-grouping/1716/2 "2020-03-11T21:22:36Z")

</div>

Hi Ruslan,

one approach to transposing with grouping is concatenating group cells into one, then transposing, then splitting them back.

See the example below.

[group-pivot.morph](https://community.easymorph.com/uploads/short-url/voIH8WsKZnRm0MVr8UsSvfEDmC1.morph) (6.0 KB)  
[Book1.xlsx](https://community.easymorph.com/uploads/short-url/9KS8BvTW91Eq6a28maWGIwxdpIB.xlsx) (11.3 KB)

 ![image](https://community.easymorph.com/uploads/default/original/2X/6/633c83fd29e5711e35d8a37b328666abe2b1f332.png)

On a side note, I'm curious how do you deal with identical repeating column names (Item/Amount)? It's a very rare case, because almost all systems/applications require column names to be different. How do the end users understand what Item/Amount is what?

---

<div class="post-metadata">

**Author:** ![raskarov](https://community.easymorph.com/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@raskarov](https://community.easymorph.com/u/raskarov)\
**Post date:** [March 15, 2020, 5:22pm UTC](https://community.easymorph.com/t/transpose-with-grouping/1716/3 "2020-03-15T17:22:44Z")

</div>

Thanks for providing a solution.

The reason why we have identical column names is because we are dealing with pricing breaks.

Let's say you want to order:

\<100 items, then price per item is 5.5,  
100-500 items, price per item 5,  
500-999 items, price per item 4, etc.

Our internal systems know how to parse this, so that's why we need it in a specific format. I will try to run your example to see if it works shortly.
