Search code examples
google-sheetsgoogle-sheets-query

Arrange query output by sheet name


thanks in advance.

Is there a way to arrange my multiple sheets query output by sheets name? so there is a separation between the two when they stack on top of each other?

=QUERY({orange!A2:I24;'apple'!A2:I26},"select Col1,Col2 where Col1 !='' ",1)

cheers to all.


Solution

  • ={query({orange!A2:I24},"select Col1,Col2, 'orange' where Col1 !='' ",1); query({'apple'!A2:I26},"select Col1,Col2, 'apple' where Col1 !='' ",1)}

    The only way is to hardcode sheet names. There's no formula to get sheet names automatically.