Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

End-to-End Retail Sales Analytics Using SQL and Power BI

Project Overview

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

Business Problem

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?

Tools and Technologies

  • 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

Dataset

This project uses the Global Superstore retail sales dataset from Kaggle.

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

Project Workflow

1. Database Creation

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.

2. Staging Table

The raw Global Superstore data was imported into a staging table. This allowed the original dataset structure to be preserved before cleaning and transformation.

3. Data Quality Checks

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

4. Normalized Relational Model

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.

5. Relationship Integrity Checks

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

6. SQL Business Analysis

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

7. Power BI Reporting Views

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

8. Power BI Dashboard

A three-page interactive Power BI dashboard was created:

  1. Executive Overview
  2. Product Profitability
  3. Market Customer Performance

The dashboard includes slicers, KPI cards, bar charts, line charts, and detailed tables.

Database Design

The project includes an EER diagram created in MySQL Workbench to show the normalized relational database structure.

EER Diagram

The model separates the original dataset into relational tables and supports more reliable querying, analysis, and reporting.

Power BI Dashboard

Page 1: Executive Overview

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.

Executive Overview

Page 2: Product Profitability

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.

Product Profitability

Page 3: Market & Customer Performance

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.

Market Customer Performance

Key Insights

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.

Business Recommendations

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.

Repository Structure


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

How to Use This Repository

To reproduce or review this project:

  1. Download the Global Superstore dataset from the Kaggle source listed above.
  2. Convert the source file to CSV format if needed.
  3. Run the SQL scripts in the sql folder in numerical order.
  4. Open the Power BI file located in the powerbi folder.
  5. Refresh the Power BI data connection if using a local MySQL database.
  6. Review the dashboard pages and screenshots.

Skills Demonstrated

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

Author

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.

About

End-to-end retail sales analytics project using MySQL and Power BI, including data quality checks, relational modeling, SQL analysis, reporting views, DAX measures, and an interactive business dashboard.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors