Search code examples
google-sheetsgoogle-sheets-formulagoogle-sheets-query

Can't query using cell reference from other functions in Google Sheets


I'm trying to get an integer value from another cell, A1, into my Google Sheets query:

=QUERY(B:F; "select B where F > "& A1 &"limit 1")

I get this error:

PARSE_ERROR: Encountered " "," ", "" at line 1, column 27. Was expecting one of: "group" ...

A1 contains a function =B1+C1 and that returns an integer. Though this query works if A1 is a hard-coded value like 100. I am not sure what is causing this error could be a parsing error or query error. Does anyone know how to fix it?

NOTES:

The referred cell, A1, has currency formatting in swedish krona(kr) that's not something custom. The regional settings are set to Sweden.


Solution

  • It works when you set the reference cell inside an Value(S13). It didn't work because of a bug in Google Sheets. Did try the query in another sheet, without Value(S13) and it worked, that confirms the bug.

    This is the workaround query:

     =QUERY(B:F; "select B where F > "& Value(S13) &"limit 1")
    

    The pseudo sheet for testing

    enter image description here