Example: Build a personalized data dashboard

This example walks you through building a Streamlit in Snowflake app that queries Snowflake data, adds a third-party charting library, and personalizes the display for each viewer. By the end, you’ll understand the core development cycle: create, deploy, edit, and redeploy.

The app uses a container runtime. Before you begin, make sure you’ve completed the prerequisites.

Set up sample data

This example uses a database called dashboard_demo. You can substitute any database and schema you have access to – just update the references in the SQL and app code to match.

Create a table with sample revenue data. Run the following SQL in a worksheet or SQL session:

CREATE OR REPLACE TABLE dashboard_demo.public.monthly_revenue (
   month DATE,
   region VARCHAR,
   revenue NUMBER(12, 2)
);

INSERT INTO dashboard_demo.public.monthly_revenue VALUES
   ('2026-01-01', 'North America', 125000.00),
   ('2026-01-01', 'Europe', 98000.00),
   ('2026-01-01', 'Asia Pacific', 87000.00),
   ('2026-02-01', 'North America', 132000.00),
   ('2026-02-01', 'Europe', 101000.00),
   ('2026-02-01', 'Asia Pacific', 93000.00),
   ('2026-03-01', 'North America', 141000.00),
   ('2026-03-01', 'Europe', 110000.00),
   ('2026-03-01', 'Asia Pacific', 99000.00);

Write the app code

On your local machine, in a project directory of your choice, create a file named streamlit_app.py with the following code. If you plan to use Snowsight, you can paste this code into the editor after creating the app.

import streamlit as st
import plotly.express as px

st.title("Revenue Dashboard")
st.write(f"Welcome, {st.user.user_name}!")

conn = st.connection("snowflake")

df = conn.query("""
    SELECT month, region, revenue
    FROM dashboard_demo.public.monthly_revenue
    ORDER BY month
""")

selected_regions = st.multiselect(
    "Filter by region",
    options=df["REGION"].unique(),
    default=df["REGION"].unique(),
)

filtered = df[df["REGION"].isin(selected_regions)]

fig = px.bar(
    filtered,
    x="MONTH",
    y="REVENUE",
    color="REGION",
    barmode="group",
    title="Monthly Revenue by Region",
)
st.plotly_chart(fig, use_container_width=True)

st.dataframe(filtered, use_container_width=True)

This app uses:

Declare dependencies

Container runtimes install packages listed in a requirements.txt file. Create a requirements.txt file alongside your streamlit_app.py:

plotly
streamlit

When the app starts, the container runtime automatically installs the declared packages. For more complex dependency scenarios, you can use a pyproject.toml file instead. For more information, see Manage dependencies for your Streamlit app.

Deploy the app

  1. Sign in to Snowsight.

  2. In the navigation menu, select Projects » Streamlit.

  3. Select + Streamlit App.

  4. Enter revenue_dashboard as the app name.

  5. Select a database and schema.

  6. Select Run on container, then select a compute pool and query warehouse.

  7. Select Create.

  8. In the editor, replace the starter code with the app code above.

  9. Upload or create the requirements.txt file by selecting + (Add) » Create new file, entering requirements.txt, and pasting the contents.

  10. Select Run.

Make a change

Try editing your app to see the development cycle in action. Add a summary metric by inserting the following two lines into streamlit_app.py, between the filtered = ... line and the fig = px.bar(...) line:

total = filtered["REVENUE"].sum()
st.metric("Total Revenue", f"${total:,.0f}")

If you’re editing in the browser, paste the lines into the editor and select Run.

For more information about the editing workflow, see Edit your Streamlit app.

Clean up

To remove the resources created in this example, run the following SQL:

DROP STREAMLIT IF EXISTS dashboard_demo.public.revenue_dashboard;
DROP TABLE IF EXISTS dashboard_demo.public.monthly_revenue;

What’s next?