How to change query based on dropdown?

I have 4 x MongoDb queries inside a project app.
I want to be able filter the data or select a different query (already filtered) by changing the drop down.
Do I need another input element such as a button to trigger the change in query or data that is displayed?

When do these queries run? All at the start and you want to change between the returned data? Or individually when the drop down is changed?

I have four different MongoDb queries. That were setup at the bottom of the page. So I think they all load when the app page first loads.
Each query is basically the same. The only difference is I filtered some data.
My goal is alter the data displayed in the table when I pick an item from a dropdown.
I do not have any preference in how I achieve this.
Maybe I could only run one DB query and store it in json in the app. Then filter the json.

Hey Christpher, new user myself but I did resolve this problem in my own work with a new query. My query is as follows.

select
name,
custom.lcf_JUrsMp5VsbwQJdHKkkOOlgBptUQIyOxZfSZiEApjCH6,
custom.lcf_QIR2fHsnLaIGeAKIzFczXzAVpIsdJxLXp97cUwVRqoy
from {{ Customers.data.response.data.data }}
where custom.lcf_QIR2fHsnLaIGeAKIzFczXzAVpIsdJxLXp97cUwVRqoy Like {{SelectCSM.value}}

Select
(insert whatever column names you wanted to select here, I had “name” and a couple ugly custom fields such as “custom.lcf_JUrsMp5VsbwQJdHKkkOOlgBptUQIyOxZfSZiEApjCH6”
from ( your data set)
where (column name) like (drop down value)

My apologies if I have interpreted your problem incorrectly!

@cer The way I would do this is with a temporary state. Create a new temp state, and set the value to something like this [ query1.data, query2.data, query3.data, query4.data ][dropdown.value] Set the values and labels of the dropdown so they coincide with the index value of the query you would want. So values: [0,1,2,3] labels: [“query1”, “query2”, “query3”,“query4”]. If you select “query4” in the dropdown, the value of the dropdown will change to 3, and the value of the temporary state will update to the value of the item in the third index, query3.data. Refer to temporarystate.value wherever you want to display that data

Think about the four different queries, if they basically different versions of the same request, use something like @Joran’s solution. You can use conditionals inside the {{ }} tags if you need to set multiple selection variables based of the same dropdown option. I.E. select {{dropdown.value == “poultry” ? “chickens” : “fish”}} from animals.

Thanks everyone. That gives me something to go off. Let me try it out tomorrow and get back to you.