Dash app architecture design help

Hi everyone,
I need some help planning how to build this app since it requires some specific things that I reckon would break the dash app if done as normal.

The main idea of the app is to have 6 radio buttons. 1 of them represents “All” or “All countries”. Each of the other 5 buttons will represent a specific “country” that together make up “All”.

When a radio button is clicked it will display 4 bar charts and 3 info boxes. The boxes contain an html.P tag inside them.

The main problem I am having trouble solving is that currently I need to make separate SQL query calls to get the data for “All” and for “country”. This means that I can’t have one single dataframe that has all of the information I need to build everything (“All” and each of the “country”)

I currently have a hidden html.Div that gets the info for “All” and am using it’s “children” as Input in a callback that will update the charts/boxes. However, this doesn’t get the info to fill in the data for “country” if a “country” radio button is selected.
I cannot figure out how to make the “Input” from dcc.RadioItems to work for both “All” and “country” since they require different SQL calls

should I create two entirely different “layouts”, one for “All” and one for “country”?

has anyone done something like this? pls let me know if u need more info
thank you

What is the problem with having separate SQL calls for each radio button?

I didn’t get why you need to make separate SQL queries since every “country” should be inside the “All” dataset. You could do a SQL query to get all the data, save it to a dataframe and then save it in a hidden div. Then you filter the data per country based on the option selected on the radio buttons.

Depending on the amount of data you have, it would considerably increase the memory footprint of your application and query the SQL database every time would be a better solution. It all depends on your requirements, the characteristics of your data, the machine you are running the application, etc.