Dynamic Filter [component] interaction

I’m struggling to figure out how to get multiple filter components such as dropdowns to interact. All filter lists are from unique values of each appropriate column in a Pandas dataframe. I come from a background in Power BI and/or OBIEE where this interaction is “built in”. It just happens like magic. With Dash, not so much. I haven’t been able to find a tutorial or example this complex.

For instance, imagine US States, Counties, and Towns being three columns of a single table each populating the list of a dropdown.

  1. A choice of a State limits the list of Counties and Towns.
  2. A choice of County limits the list of States and Towns.
  3. A choice of Town limits the list of States and Counties.

Just to add a little more complexity, here are two other factors.

  1. Each list should have an “All” [no selection] option.
  2. If a change of selection allows the selection in another list to still be valid, that selection should not change. For instance, Centerville exists in many States. Changing the State drowdown to another State that has a Centerville should allow it to remain selected. If the section is no longer valid, the selected value should revert to “All” in the full list of filtered [allowed] values [given the other two selections]. This implies that although Centerville exists in another State that was chosen, it probably won’t be in the same County in a different State, therefore the County selection would have to revert to All. That list would, most likely, have only two values: All and the actual County in the newly selected State that Centerville is in.

I hope that isn’t too confusing. I look forward to any advice or reference to tutorials or examples that deal with filter component interaction.

Welcome to the Dash Plotly community @compunuke
Have you taken a look at the dash chained callbacks section
I think it’s a good place to start.

Yes. Thanks for pointing out the relevant section of the documentation, but the example is very simplistic. Chaining, of course, will be necessary. However, in my use case, the values come from unique filtered lists of values from the appropriate columns of dataframe rows that are filtered by the input selector choice and by the third dropdown. For example, choosing a County must update the State options for all States that have a County by that name and then update the Towns list for all Towns that have a County by the selected name and then, if a State was chosen, further filtered by the State value too. If no State was previously selected, then the Towns list would have all Towns in all States that have a County by the chosen name.

This requires the callback to be activated by the dropdown selection that activated it [the Input value] and then to be aware of the current selection choices of the two other dropdowns that did not activate the callback. I’m not sure how to read the currently selected options of the dropdowns not passed as the Input. I’m also not sure how to repopulate the dropdowns that are outputs preserving the previously selected value if it is still relevant or reverting to the default “All” choice if the previous selection is no longer relevant.

As I mentioned, this happens automatically by filter interaction with modern BI tools like Power BI, OBIEE, and I suspect also Tableau & Qlik. It seems to require pretty sophisticated Python and Dash code to accomplish. If anyone else has wrestled with these complexities, from a standard set of three or more interdependent filters, please offer some guidance.