This project is an end-to-end retail sales analytics solution built using MySQL and Power BI. The goal was to transform a raw retail sales dataset into a structured relational database, perform SQL-based data quality checks and business analysis, and build an interactive Power BI dashboard for executive, product, market, and customer performance insights.
The project follows a complete analytics workflow:
Raw Dataset
→ MySQL Staging Table
→ Data Quality Checks
→ Normalized Relational Model
→ Relationship Integrity Checks
→ SQL Business Analysis
→ Power BI Reporting Views
→ Power BI Data Model
→ DAX Measures
→ Interactive Dashboard
Retail businesses need reliable visibility into sales, profit, customer behavior, product performance, and market-level trends. Raw transactional data is often not ready for direct reporting because it may contain duplicates, inconsistent formats, missing values, and unstructured relationships.
This project addresses the following business questions:
- What are the overall sales, profit, order, and customer performance indicators?
- Which product categories and products generate the highest sales and profit?
- Which products are loss-making or show weak profitability?
- Which markets, countries, and customer segments contribute most to performance?
- How can SQL and Power BI be combined to create a reliable business intelligence workflow?
- MySQL Workbench — database creation, SQL scripting, EER diagram, data modeling
- MySQL — relational database management
- Power BI Desktop — dashboard creation and data visualization
- DAX — business measures and KPI calculations
- SQL — data cleaning, validation, transformation, analysis, and reporting views
- Excel / CSV — source data preparation for SQL import
- GitHub — portfolio documentation and version control
This project uses the Global Superstore retail sales dataset from Kaggle.
- Source platform: Kaggle
- Dataset name: Global Superstore dataset
- Source link: https://www.kaggle.com/code/yorkyong/global-superstore-dataset-data-exploration/input
The original dataset was provided in Excel format and was converted to CSV format for importing into MySQL.
The raw dataset is not included in this repository due to licensing and file-size considerations. More details are available in:
data/README.md
A dedicated MySQL database was created for the project. The workflow starts by creating the project database and setting up the environment for staging, cleaning, normalization, and reporting.
The raw Global Superstore data was imported into a staging table. This allowed the original dataset structure to be preserved before cleaning and transformation.
SQL queries were used to inspect the dataset for:
- Row counts
- Duplicate records
- Missing values
- Date format issues
- Numeric field consistency
- Product, customer, location, and order-level issues
The staging table was transformed into a normalized relational model with separate tables for:
- Orders
- Order items
- Customers
- Products
- Categories
- Locations
This improved data structure, reduced redundancy, and created a more reliable foundation for analysis.
Foreign key relationships were validated to confirm that:
- Order items matched valid orders
- Orders matched valid customers
- Orders matched valid locations
- Products matched valid categories
- No orphan records existed in the relational structure
Business-focused SQL queries were created to analyze:
- Overall sales and profit
- Yearly performance
- Category and sub-category performance
- Segment performance
- Market and country performance
- Discount and loss-making patterns
- Top and bottom product profitability
SQL views were created specifically for Power BI reporting. These views simplified the dashboard-building process and separated reporting logic from the raw database structure.
Main reporting views included:
- Sales fact view
- Date dimension view
- Product performance view
- Customer performance view
- Market performance view
- Monthly sales trend view
A three-page interactive Power BI dashboard was created:
- Executive Overview
- Product Profitability
- Market Customer Performance
The dashboard includes slicers, KPI cards, bar charts, line charts, and detailed tables.
The project includes an EER diagram created in MySQL Workbench to show the normalized relational database structure.
The model separates the original dataset into relational tables and supports more reliable querying, analysis, and reporting.
This page provides a high-level business summary, including total sales, total profit, profit margin, total orders, total customers, average order value, monthly sales trend, sales by category, and sales by market.
This page focuses on product and category performance. It highlights top products by sales, top products by profit, profit margin by sub-category, and lowest-profit products.
This page analyzes market, country, customer segment, and customer-level performance. It includes sales by market, profit margin by country, sales by segment, and top customers by sales.
Key findings from the analysis include:
- Total sales reached approximately 12.64M.
- Total profit reached approximately 1.47M.
- Overall profit margin was approximately 11.61%.
- The business generated approximately 25K orders from around 5K customers.
- Technology generated the highest category-level sales.
- Some high-sales products were not necessarily the most profitable.
- Several products had negative profit, showing the importance of profitability analysis beyond sales volume.
- APAC, EU, and US were among the strongest markets by sales.
- Customer-level performance varied significantly across segments and regions.
Based on the analysis, the following recommendations can support better business decisions:
- Monitor loss-making products and investigate whether discounts, shipping costs, or pricing strategy are causing negative profit.
- Prioritize high-margin products and sub-categories when planning sales and marketing campaigns.
- Use market-level analysis to focus growth strategies on regions with strong sales and profitability.
- Review discount strategies for products that generate high revenue but weak profit.
- Track customer segments separately because sales volume and profitability patterns differ by segment.
- Maintain SQL-based reporting views to ensure dashboard consistency and reproducibility.
retail-sales-analytics-sql-powerbi
│
├── README.md
│
├── data
│ └── README.md
│
├── sql
│ ├── 01\\\_create\\\_database.sql
│ ├── 02\\\_create\\\_staging\\\_table.sql
│ ├── 03\\\_import\\\_staging\\\_data.sql
│ ├── 04\\\_data\\\_quality\\\_checks.sql
│ ├── 05\\\_create\\\_normalized\\\_tables.sql
│ ├── 06\\\_populate\\\_normalized\\\_tables.sql
│ ├── 07\\\_relationship\\\_integrity\\\_checks.sql
│ ├── 08\\\_business\\\_analysis\\\_queries.sql
│ └── 09\\\_create\\\_powerbi\\\_views.sql
│
├── powerbi
│ ├── retail\\\_sales\\\_analytics\\\_dashboard.pbix
│ └── screenshots
│ ├── 01\\\_executive\\\_overview.png
│ ├── 02\\\_product\\\_profitability.png
│ └── 03\\\_market\\\_customer\\\_performance.png
│
├── docs
│ ├── eer\\\_diagram.png
│ └── project\\\_summary.md
│
└── assets
To reproduce or review this project:
- Download the Global Superstore dataset from the Kaggle source listed above.
- Convert the source file to CSV format if needed.
- Run the SQL scripts in the
sqlfolder in numerical order. - Open the Power BI file located in the
powerbifolder. - Refresh the Power BI data connection if using a local MySQL database.
- Review the dashboard pages and screenshots.
This project demonstrates:
- SQL database creation and scripting
- Data staging and quality checks
- Data cleaning and transformation
- Relational database design
- EER diagram creation
- Relationship integrity validation
- Business analysis using SQL
- Power BI reporting view creation
- Power BI data modeling
- DAX measure creation
- Dashboard design and storytelling
- Business intelligence reporting
- End-to-end portfolio project documentation
Mahdi Dadgar
Career switcher into Data Analytics, Business Intelligence, Data Science, and AI.
Background: PhD in Animal Science and Animal Nutrition.
Focus: SQL, Power BI, Python, machine learning, business analytics, and responsible AI.



