As promised from Twitter I have taken a peek at your app and its source code this morning!
If I understand the execution of your app and its functions I know why it seems as though
@st.cache isn’t working for you.
it is running but when it’s finished the checks, it always detects changes in the function/parameters!
So, just a review on
@st.cache, it remembers the last call of the function that it decorates and specifically checks 3 things: (see here for more info)
- The name of the function
- The actual code that makes up the body of the function
- The input parameters that you called the function with
It’s the 3rd one that’s tripping cache up in your app! The first parameter in
DAX_Query_Value. The issue is
DAX_Query_Value changes depending on the user input from the sidebar multi-select and select boxes!
This means that on the first run,
DAX_Query_Value has the “default value”, then once the data is pulled from the PowerBI API call, the user options are created and depending on what’s chosen by the user this changes the
DAX_Query_Value thus triggering
@st.cache to rerun the function.
The best way to solve this is to have a function that just gets all the data you want, and then another that filters the data frame to have only the data that the user selects.
Let me know if this solves your problem,