Google Sheets – Combine Two QUERY Results into One Column

formulasgoogle sheetsgoogle-sheets-arrayformulagoogle-sheets-query

I have the following QUERY

=query(XX!A2:A;" select A where A>'50' ")

and

=query(YY!A2:A;" select A where A>'50' ")

how do I combine these two data sources so I don't have to have two separate columns they process data to?

  • best would be if the 1st row from XX is followed by the 1st row of YY, 2nd row followed by 2nd row… and so on
  • If the above option is not easily possible, it is OK for one query to be followed by the second one (if I expect correctly that the start of the second will be moved with newly added data into the first one)

Best Answer

the most easier is to do:

={QUERY(XX!A2:A; "select A where A>'50'");
  QUERY(YY!A2:A; "select A where A>'50'")}

={QUERY(XX!A2:A; "select A where A is not null");
  QUERY(YY!A2:A; "select A where A is not null")}

to zip 2 queries you can do:

=QUERY({{ARRAYFORMULA(ROW(INDIRECT("A1:A"&COUNTA(QUERY(XX!A2:A; 
 "select A where A is not null")))))\QUERY(XX!A2:A; 
 "select A where A is not null")};
        {ARRAYFORMULA(ROW(INDIRECT("A1:A"&COUNTA(QUERY(YY!A2:A; 
 "select A where A is not null")))))\QUERY(YY!A2:A; 
 "select A where A is not null")}}; 
 "select Col2 order by Col1 asc")