I want yo use the query result d perform activities inside the if statment. if company_choice == the fist element in the array perform this if the second element in the array to that.
st.markdown(f"<h1 style='{style_heading}'>Ridesharing Income</h1>", unsafe_allow_html=True)
company = df_query['Company_Name'].unique()
company_choice = st.sidebar.selectbox('Select Company Name:', company)
report = 'Report Type','List','Summary'
report_choice = st.sidebar.selectbox('Type of Report:', report)
year = df_query['Year'].unique().astype(int)
year_choice = st.sidebar.selectbox('Year', year)
if company_choice == company_choice[0]:
st.markdown(f"<h2 style='{style_heading}'>All Companies Income Reports</h2>", unsafe_allow_html=True)
if company_choice == company_choice[1]:
Do this ....
if company_choice == company_choice[2]:
Do that ......
if company_choice == company_choice[2]:
Do something else
.
.
.
Yeah I agree with @mathcatsand here, it sounds like that’s what you are trying to do
Btw, you can also put your if statements into a function that you assign to on_change if you wanted to have those statements execute before the entire page re-runs. If so, you would also need to assign a key to selectbox and can then access the result through the session state.
company_choice = st.sidebar.selectbox('Select Company Name:', company, key='company_choice', on_change=if_function, args=(company, ))
def if_function(company: list):
if st.session_state.company_choice == company[0]:
st.markdown(f"<h2 style='{style_heading}'>All Companies Income Reports</h2>", unsafe_allow_html=True)
...
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.