Search code examples
sortinggoogle-sheetsgoogle-sheets-formulagoogle-sheets-query

Stack multiple columns into one


I want to do a simple task but somehow I'm unable to do it. Assume that I have one column like:

a
z
e
r
t

How can I create a new column with the same value twice with the following result:

a
a
z
z
e
e
r
r
t
t

I've already tried to double my column and do something like :

=TRANSPOSE(SPLIT(JOIN(";",A:A,B:B),";"))

but it creates:

a
z
e
r
t
a
z
e
r
t

I get inspired by this answer so far.


Solution

  • Try this:

    =SORT({A1:A5;A1:A5})

    Here we use:


    Accounting your comment, then you may use this formula:

    =QUERY(SORT(ArrayFormula({row(A1:A5),A1:A5;row(A1:A5),A1:A5})),"select Col2")

    The idea is to use additional column of data with number of row, then sort by row, then query to get only values.


    And joinsplit method will do the same: =TRANSPOSE(SPLIT(JOIN(",",ARRAYFORMULA(CONCAT(A1:A5&",",A1:A5))),","))

    Here we use range only two times, so this is easier to use. Also see Concat + ArrayFormula sample.