1

I'm trying to concatenate 2 two-dimensional arrays of different size into a single array/table. Both arrays are a result of a Query with a Group BY clause)

Example:

Array 1:

Account | Amount

Google 10,000

IBM 12,000

Array 2:

Account | Type | Amount

Yahoo Enterprise 8,000

Tesla Enterprise 14,000

Microsoft Enterprise 4,000

With a one-dimensional array, I would use:

={
{QUERY(A1:B1,"select A,B"),""}
;
QUERY(A2:F2,"select A,B,C")
}

OR

=ARRAYFORMULA( {
{A1:B1, SUBSTITUTE(SPLIT(REPT(12, 4), 2), 1, )}
;
A2:F2
})

But these don't seem to work for a two-dimensional array, I get the following error: "Function ARRAY_ROW parameter 2 has mismatched row size. Expected: 3. Actual: 1." The empty cell substitution seems to only work for the 1st row, even when I combine it with ArrayFormula.

I'd appreciate suggestions on how to resolve this! Thanks

JvdV
  • 70,606
  • 8
  • 39
  • 70
Alonr
  • 11
  • 2

1 Answers1

3

You could add a blank column when querying the first table, as shown on this answer, so that both have the same amount of columns, and the concatenate both queries:

={QUERY(D1:F4,"SELECT *");QUERY(A2:B3,"SELECT A,' ',B LABEL ' ' ''")}

enter image description here

Note:

  • In this example, the headers are provided by the second table.
Iamblichus
  • 18,540
  • 2
  • 11
  • 27