Search code examples
google-sheetsdropdowngoogle-sheets-formulagoogle-sheets-querygoogle-query-language

Making query return rows that meet the criteria of a drop down in google sheets


I am trying to have query search through named range SubListTable ('Sub List'!A1:I188) on a column of that table named Instrument ('Sub List'!D:D) and return only rows that have an instrument from a drop down SubByInstrument!A2

The SubByInstrument sheet is on the same page as the query.

Currently my query which will only return an error is as follows:

=QUERY(SubListTable,"SELECT * Where "Instrument""=""A2""",-1)")

I know that Instrument and A2 are correctly referencing what I want, where A2 is a a drop-down that will allow us to look at people who specialize in that instrument


Solution

  • if A2 is text string try:

    =QUERY({SubListTable}, "where Col4 = '"&A2&"'", -1)
    

    if A2 is number use:

    =QUERY({SubListTable}, "where Col4 = "&A2, -1)