Search code examples
sqlgoogle-sheetsgoogle-sheets-formulaoffsetgoogle-query-language

Return a specific cell in a Google Sheets QUERY function


Take the following spreadsheet:

enter image description here

I want to create a query that returns the values in columns A and B where A matches 'f' and also return the value that is in cell D1 (Test Cell).

Here is the Query that I wrote:

=QUERY(A2:B7,"select A,B,'"&D1&"' where A='f'")

This is what I expected:

enter image description here

This is what actually happens:

enter image description here

I'm not sure where the value of "Test Cell()" in C11 is coming from and I suspect it's a bug. Is there a way to accomplish what I am attempting?


Solution

  • try:

    =QUERY(A2:B7, "select A,B,'"&D1&"' where A='f' label '"&D1&"'''")
    

    or:

    =QUERY(QUERY(A2:B7, "select A,B,'"&D1&"' where A='f'", ), "offset 1", )