I\'m having trouble figuring out a fairly simple QUERY statement in Google Spreadsheets. I\'m trying to use a cell reference instead of static values and I\'m running into t
Old Thread but I found this on my journey to the below answer and figure someone else might need it too.
=IFERROR(ArrayFormula(query(index(Sheet3!A:C&""),"select* Where Col1="""&B1&""" ")), ARRAYFORMULA({"* *","no cells","match"}));
Here is a simply built text Filter from a 3 column data set (A,B and C) located in "sheet3" into the current sheet and calling a comparison to a cell from the current sheet to filter within Col1(A)
.
This bit is just to get rid of the #N/A
error if the filter turns up no results //ARRAYFORMULA({"* *","no cells","match"}))
I only have a workaround here.
In this special case, I would use the FILTER
function instead of QUERY
:
=FILTER(Responses!B:B,Responses!G:G=B1)
Assuming that your data is on the "Responses" sheet, but your condition (cell reference) is in the actual sheet's B1 cell.
Hope it helps.
UPDATE:
After some search for the original question: The problem with your formula is definitely the second &
sign which assumes that you would like to concatenate something more to your WHERE
statement. Try to remove it. If it still doesn't work, then try this:
=QUERY(Responses!B1:I, "Select B where G matches '^.\*($" & B1 & ").\*$'")
- I have not tried it, but it helped in another post: Query with range of values for WHERE clause?