How 13,412 rows of messy transaction data became a dashboard that helps the management team make confident decisions on stock and promotions.
I exported the data from the point-of-sale system as a CSV. Before changing anything, I opened it in Excel and skimmed through it to spot anything unusual. Here are the first 8 rows (13,412 rows and 8 columns in total). Red cells highlight the issues I found.
| order_id | order_date | customer | city | category | qty | price | status |
|---|---|---|---|---|---|---|---|
| 1001 | 05/01/2025 | Budi Santoso | Jakarta | Electronics | 2 | Rp 350.000 | Completed |
| 1002 | 2025-01-07 | siti aminah | jkt | Fashion | 1 | 150000 | completed |
| 1002 | 2025-01-07 | siti aminah | jkt | Fashion | 1 | 150000 | completed |
| 1003 | 12 Jan 2025 | Andi | Bandung | electronics | -1 | 350000 | Cancelled |
| 1004 | 15/01/2025 | Dewi Lestari | Surabaya | Household | 3 | (empty) | Completed |
| 1005 | 20/01/2025 | Rina | Bandung | Fashion | 2 | Rp 120.000 | Completed |
| 1006 | 3/2/25 | Agus | Medan | Food | 5 | 45000 | Completed |
| 1007 | 03/02/2025 | Budi Santoso | Jakarta | Electronics | 1 | 350000 | completed |
Issues found: mixed date formats, prices stored as text ("Rp 350.000"), inconsistent city and category spellings (jkt, Jakarta, electronics), duplicate order IDs, negative quantities, and missing prices.
I used Python (pandas) because the dataset has well over ten thousand rows and the rules need to be repeatable. Every decision is documented so it can be explained and defended.
import pandas as pd
df = pd.read_csv("sales_raw.csv")
# 1. Remove duplicates based on order_id
df = df.drop_duplicates(subset="order_id")
# 2. Standardize date formats
df["order_date"] = pd.to_datetime(df["order_date"], dayfirst=True, errors="coerce")
# 3. Price: strip "Rp" and dots, convert to a number
df["price"] = (df["price"].astype(str)
.str.replace(r"[^0-9]", "", regex=True)
.replace("", None).astype(float))
# 4. Standardize text
df["city"] = df["city"].str.strip().str.title().replace({"Jkt": "Jakarta"})
df["category"] = df["category"].str.strip().str.title()
df["status"] = df["status"].str.strip().str.capitalize()
# 5. Fill missing prices with the median per category
df["price"] = df["price"].fillna(df.groupby("category")["price"].transform("median"))
# 6. Drop cancelled orders and invalid quantities
df = df[(df["status"] == "Completed") & (df["qty"] > 0)]
As a result, the cells that were red are now consistent (green). Duplicate rows and cancelled orders (struck through) are removed, and I added a total column.
| order_id | order_date | customer | city | category | qty | price | total |
|---|---|---|---|---|---|---|---|
| 1001 | 2025-01-05 | Budi Santoso | Jakarta | Electronics | 2 | 350000 | 700000 |
| 1002 | 2025-01-07 | Siti Aminah | Jakarta | Fashion | 1 | 150000 | 150000 |
| 1003 | 2025-01-12 | Andi | Bandung | Electronics | -1 | 350000 | removed (cancelled) |
| 1004 | 2025-01-15 | Dewi Lestari | Surabaya | Household | 3 | 85000 | 255000 |
| 1005 | 2025-01-20 | Rina | Bandung | Fashion | 2 | 120000 | 240000 |
| 1006 | 2025-02-03 | Agus | Medan | Food | 5 | 45000 | 225000 |
The average is easily pulled up by high-priced items, while the median stays more stable. Only 0.6% of rows were filled, so the impact on totals is minimal. I noted this assumption in the documentation.
I loaded the clean data into MySQL and calculated the metrics that answer the business questions. Here are sample queries for monthly revenue and category contribution:
-- Revenue per month
SELECT DATE_FORMAT(order_date, '%Y-%m') AS month,
COUNT(*) AS order_count,
SUM(qty * price) AS revenue
FROM sales_clean
GROUP BY month
ORDER BY month;
-- Contribution by category
SELECT category,
SUM(qty * price) AS revenue,
ROUND(100 * SUM(qty * price) /
(SELECT SUM(qty * price) FROM sales_clean), 1) AS percent
FROM sales_clean
GROUP BY category
ORDER BY revenue DESC;
I connected the query results to Power BI. Below is a condensed version of the dashboard.