1
votes

How do I correctly reference a cell in a sheet such that a query can use the string in the cell as a filter in the query where statement?

The below query fails in the where statement with:

"Error:Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: BADO".

"BADO" is the string in cell C1 referenced in the where statement and is a valid value in Col2 in the importrange sheet.

The query returns all date if "Col2" is entered into cell C1. I've tried several other variations to no avail.

{=QUERY(importrange("1cCQQA3DYwuiSKokzcuqhnUPVV8-Ok2JAZUzG6ryxLf8","$A$2:$F"),
        "select * where (Col2="&C1&")")}

Below is my test sheet:

https://docs.google.com/spreadsheets/d/1RY2AXali01-N0fd-zBPPJDO-4vPuoRGsG5dSMn1NBJU/edit?usp=sharing

1

1 Answers

0
votes

The formula is right however the mistake is that in where cluase, Col2 requires a string value but we are passing BADO. ideally the synatx needs to be 'BADO' with single quotes. So just added the single quotes in where clause of the formula.

=QUERY(importrange("1cCQQA3DYwuiSKokzcuqhnUPVV8-Ok2JAZUzG6ryxLf8","$A$2:$F"),"select * 
where Col2='"&$C$1&"'")

Hope this could help.