How to execute a query based on dropdown selection in Google Sheets

Hey everyone, I need some help with my Google Sheets setup.

I’m trying to create a dynamic table that changes based on what someone picks from a dropdown menu. Here’s what I want to happen:

  • I have a dropdown in cell C2 on my ‘Healthcare’ sheet.
  • When someone selects ‘Healthcare’ from that dropdown, I want a specific query to run automatically.
  • The query should pull data from multiple sheets and filter it.

Right now I’m thinking about putting this formula in cell A4:

=query({DataSheet1!A1:P; DataSheet2!A1:P; DataSheet3!A1:P; DataSheet4!A1:P}, "select * where Col2 contains 'Healthcare'",0)

But I only want this to execute when C2 equals ‘Healthcare’. Is there a way to wrap this in an IF statement to make it conditional? Something like:

=if(C2="Healthcare", query({DataSheet1!A1:P; DataSheet2!A1:P; DataSheet3!A1:P; DataSheet4!A1:P}, "select * where Col2 contains 'Healthcare'",0), "")

Would this approach work with just formulas or do I need to write a custom script with onEdit triggers? I’m hoping to keep it simple with just functions if possible.

Any guidance would be really appreciated!

yep, that if statement should do the trick! just tested a similar setup. just be sure your dropdown values match exactly, since it’s case sensitive. for a better user experience, consider using “Please select an option” instead of leaving it blank.

Your IF approach works great! Just one tweak - instead of returning an empty string when nothing’s selected, try “Select a category to view data.” Users will know exactly what to do. Heads up though: querying multiple sheets can get sluggish with big datasets. I hit this on a project where each sheet had thousands of rows. The formula took several seconds every time someone changed the dropdown - super annoying for users. If it gets slow, consider combining everything into one master sheet first, then query from there. But for typical datasets, your formula should work fine without any custom scripts.