Search code examples
google-sheetsgoogle-sheets-formulatransposearray-formulasgoogle-sheets-query

How can I repeat a query with multiple columns N times with a join who only take ONE column?


I am using this:

=IFERROR(QUERY(Opgivelser!A:E; "select D,A,B where E = TRUE");"Vælg fordybelsesområder")

for this:

enter image description here

And it works as intended but I also want to repeat it i.e twice or based on a cells value i.e D2.

I have tried to to use this:

=ArrayFormula(TRANSPOSE(SPLIT(JOIN(","; IFERROR(REPT(IFERROR(QUERY(Opgivelser!A:E; "select D,A,B where E = TRUE"); "Vælg fordybelsesområder") & ","; D2))); ",")))

But that one prompts an error about ONE row/column.

What will I have to change? Or is there an even more simple or logical syntax for this?


Solution

  • try:

    =ARRAYFORMULA(SPLIT(TRANSPOSE(SPLIT(REPT(QUERY(TRANSPOSE("♠"&
     QUERY(TRANSPOSE("♦"&IFERROR(QUERY(Opgivelser!A:E; 
     "select D,A,B where E = TRUE"); "Vælg fordybelsesområder"))
     ;;9^9));;9^9); F1); "♠")); "♦"))
    

    0