I feel almost certain this has been answered, but in a time crunch I am hoping someone can outline the solution for me, as my searches returned variations that were not quite what I wanted.
I have data that is arranged with multiple columns per entry:
I would like to transpose the columns data into rows duplicating the first two columns as indices:
Much appreciation for any solutions.
Best Answer
As you have noted, there is a precedent for this on either StackOverflow or webapps but I couldn't find it, so I've recreated an equivalent solution. I'm pretty sure that this formula can be simplified BUT it does work - so simplification is for another day/user.
Use this formula (assumes that the raw data is in sheet="Data"):
=query({{"Number","Name","Code"};sort(query({query({query({query({query(Data!A2:B6) ,query(Data!A2:F6) },"select Col1, Col2, Col5 where Col1 = Col3");query({query(Data!A2:B6) ,query(Data!A2:F6) },"select Col1, Col2, Col6 where Col1 = Col3 and Col6 is not null")});query({query(Data!A2:B6) ,query(Data!A2:F6) },"select Col1, Col2, Col7 where Col1 = Col3 and Col7 is not null")});query({query(Data!A2:B6) ,query(Data!A2:F6) },"select Col1, Col2, Col8 where Col1 = Col3 and Col8 is not null")}),2,true)})
The logic is
{;}
SORT
BEFORE
AFTER