Search code examples
google-sheetsgoogle-sheets-formula

Using data validation (drop down) with Query


So, I have this formula:

=QUERY({
IMPORTRANGE('Data Sources'!$C$3, "A1:M16000");
IMPORTRANGE('Data Sources'!$C$4, "A1:M16000");
IMPORTRANGE('Data Sources'!$C$5, "A1:M16000")
}, "SELECT Col3, Col8, Col9, Col10, Col12, Col13 WHERE Col1 = 'GOLD - COMMODITY EXCHANGE INC.' ORDER BY Col3 DESC LIMIT 260", 1) 

...where I want to reference the GOLD - COMMODITY EXCHANGE INC. to a drop down. My goal is to be able to change it when needed without editing the formula itself.

How can I point/reference this to an existing cell? TIA.

I'm pretty new to using Query formula and got no luck getting solution online. Tried AI to for answers but got no solution.

The formula works and I just want to enhance it.


Solution

  • Assuming Cell_A1 has the drop-down:

    =QUERY({
    IMPORTRANGE('Data Sources'!$C$3, "A1:M16000");
    IMPORTRANGE('Data Sources'!$C$4, "A1:M16000");
    IMPORTRANGE('Data Sources'!$C$5, "A1:M16000")
    }, "SELECT Col3, Col8, Col9, Col10, Col12, Col13 WHERE Col1 = '"&A1&"' ORDER BY Col3 DESC LIMIT 260", 1)