Build an Analytics Dashboard with Streamlit
Mar 30, 2026·11 min read
Streamlit lets you turn Python scripts into shareable web apps in minutes. In this tutorial, we'll build an interactive analytics dashboard from a CSV file — no frontend experience required.
Setup
Install Streamlit and create a new Python file:
pip install streamlit pandas plotly
Load and Explore
Start by loading your CSV and showing a preview of the data:
import streamlit as st
import pandas as pd
st.set_page_config(page_title="Sales Dashboard", layout="wide")
df = pd.read_csv("sales.csv")
st.dataframe(df.head(100))
Add Filters
Streamlit widgets bind directly to variables. Add a sidebar with date range and category filters:
st.sidebar.header("Filters")
category = st.sidebar.selectbox("Category", df["category"].unique())
start_date = st.sidebar.date_input("Start date", df["date"].min())
end_date = st.sidebar.date_input("End date", df["date"].max())
filtered = df[(df["category"] == category) &
(df["date"] >= start_date) &
(df["date"] <= end_date)]
Visualise
Use Plotly for interactive charts. A line chart of sales over time, a bar chart by subcategory, and a KPI summary:
import plotly.express as px
col1, col2, col3 = st.columns(3)
col1.metric("Total Sales", f"${filtered['revenue'].sum():,.0f}")
col2.metric("Avg Order Value", f"${filtered['revenue'].mean():,.2f}")
col3.metric("Orders", len(filtered))
fig = px.line(filtered, x="date", y="revenue", title="Sales Over Time")
st.plotly_chart(fig, use_container_width=True)
Deploy
Push your script to GitHub, connect it to Streamlit Community Cloud, and your dashboard is live in minutes.

