Build a Sales Dashboard with Streamlit
A local CSV dashboard with filters, metrics, charts and automated checks.

What you will build
The default dashboard shows GBP 100.00 across five orders. Selecting Books shows GBP 40.00 across three orders. Two AppTest tests also cover empty results and reversed dates.
This workbook is for readers who can run a Python script. It includes a small local example, explanations, exercises and worked answers. The package was checked on Windows with Python 3.13.17. Pinned package versions and setup instructions are included; they are not a claim to be the latest releases.
Read a sample
The following two sections are taken from the practical download edition.
Start with data you can reconcile by hand
A dashboard is easier to trust when you can explain its totals. The supplied CSV has five rows and one row per order. Amounts are stored as integer pence, and the complete dataset totals 10,000 pence. Two categories make the category filter easy to check.
This edition uses a local CSV rather than the database setup in the original article. That keeps the first run self-contained and removes the need to configure credentials. The skills transfer to a database-backed application, but connection management and database deployment are outside this package.
One row per order is an important assumption. If your real dataset contains multiple line items per order, sum the line values but count distinct order IDs when calculating average order value. If rows are duplicated by a join, correct the data relationship before drawing a chart.
Keep every display on the same filtered data
The date inputs initialise from the minimum and maximum dates in the file. The category selector contains an explicit All categories option and the available categories. A single selected DataFrame then supplies the metrics, charts, table and CSV download.
Using one filtered dataset prevents a common dashboard defect: a chart responds to a filter while the summary number still represents the full dataset. In this example, date boundaries are inclusive. For timestamps, decide how an end date maps to a time boundary instead of relying on midnight accidentally.
If the start date is after the end date, the application displays an error and stops that run. If the dates are valid but match no sales, it displays zero metrics and an explanatory message. These are distinct states and should be tested separately.
Inside the complete guide
- Start with data you can reconcile by hand
- Keep every display on the same filtered data
- Calculate useful metrics
- Add charts and a useful download
- Test the rendered application
- Exercises and worked answers
Files in your download
The 6-page PDF includes the walkthrough and complete source listing. The examples folder contains:
app.pytest_dashboard.pysales.csvREADME.txtrequirements.txt
Scope and source material
This is a focused learning project with synthetic example data. It does not include hosted services or production deployment. This revised edition is based on previously published articles and uses replacement runnable examples; it is not a verbatim reprint.
Get the guide on Payhip — £4.99