Skip to content

Shohag-DataAnalyst/Retail-Sales-Analytics-Dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

24 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


Retail Sales Analytics Dashboard

An end-to-end data analytics project using SQL, PostgreSQL, DAX, and Power BI.

This project simulates the work of a junior data analyst at a retail company:
you design the schema, load raw CSV files into PostgreSQL, build views, create DAX measures, and deliver interactive dashboards in Power BI.


๐Ÿ“Œ Project Overview

This project analyzes retail sales performance across multiple years.
The goal was to build a complete, end-to-end analytics workflow including:

  • SQL-based data cleaning & transformation
  • Data modeling in PostgreSQL
  • Calculation of key KPIs using DAX
  • Interactive Power BI dashboards for insights & decision-making

๐Ÿ“Œ Business Questions Answered

This project was designed to answer key business questions for a retail company.

1. Sales Performance

  • What is the total revenue for each year?
  • Which categories contribute the most to sales?
  • What are the sales trends over time (monthly, quarterly, yearly)?
  • Which products generate the highest revenue and profit?

2. Customer Insights

  • How do different customer segments (gender, income, etc.) contribute to revenue?
  • Which customer groups purchase the highest-margin products?

3. Product Performance

  • Which products have the highest gross profit?
  • What are the top-performing products by revenue?
  • Which categories and subcategories consistently perform well?

4. Returns Analysis

  • What is the return rate (%) by product category?
  • Which products have high return rates and low profitability?
  • Are certain territories linked to higher return volume?

5. Time Intelligence Analysis

  • How does monthly revenue change over time?
  • What is the 3-month moving average trend?
  • What is the year-over-year (YoY) revenue growth?

๐Ÿ›  Tools & Technologies

  • SQL (PostgreSQL) โ€“ for data cleaning, joining, calculations
  • Power BI โ€“ for data modeling, DAX measures, visualization
  • DAX โ€“ custom KPI calculations
  • GitHub โ€“ version control & project documentation

๐Ÿงฑ Dataset & Data Model

The project is built on a simple retail star schema:

Fact Tables

  • fact_sales โ€“ one row per order line (date, customer, product, territory, quantity)
  • returns_data โ€“ product returns by date, territory, and product

Dimension Tables

  • calendar โ€“ full date table (year, quarter, month, weekdays, etc.)
  • dim_customer โ€“ customer demographics and income
  • dim_product โ€“ product details (SKU, name, price, cost, attributes)
  • dim_product_subcategories โ€“ product subcategories
  • dim_product_categories โ€“ product categories
  • dim_territory โ€“ region, country, continent

Table Relationships

  • fact_sales.order_date โ†’ calendar.calendar_date
  • fact_sales.customer_key โ†’ dim_customer.customer_key
  • fact_sales.product_key โ†’ dim_product.product_key
  • fact_sales.territory_key โ†’ dim_territory.territory_key
  • dim_product.product_subcategory_key โ†’ dim_product_subcategories.product_subcategory_key
  • dim_product_subcategories.product_category_key โ†’ dim_product_categories.product_category_key
  • returns_data.product_key โ†’ dim_product.product_key
  • returns_data.territory_key โ†’ dim_territory.territory_key
  • returns_data.return_date โ†’ calendar.calendar_date

๐Ÿ“ Project Structure

Retail-Sales-Analytics-Dashboard/
โ”‚
โ”œโ”€โ”€ README.md                               # Full project documentation
โ”œโ”€โ”€ Retail-Sales-Analytics-Dashboard.pbix   # Final Power BI dashboard
โ”‚
โ”œโ”€โ”€ schema.sql                              # SQL script: creates dimension & fact tables
โ”œโ”€โ”€ vw_sales.sql                            # SQL view used by Power BI
โ”œโ”€โ”€ analysis_queries.sql                    # Example analysis queries used in SQL exploration
โ”‚
โ””โ”€โ”€ Screenshots/                            # Dashboard images
    โ”œโ”€โ”€ Page1_ExecutiveSummary.png
    โ”œโ”€โ”€ Page2_SalesTrends.png
    โ”œโ”€โ”€ Page3_ProductInsights.png
    โ””โ”€โ”€ Page4_ReturnsAnalysis.png

๐Ÿ“Š Dashboards Included

1๏ธโƒฃ Executive Summary

  • Total Revenue
  • Gross Profit
  • Profit Margin %
  • Revenue Trend Over Time
  • Revenue by Category

2๏ธโƒฃ Sales Trends Page

  • Monthly Revenue Trend
  • 3-Month Moving Average
  • YoY Revenue Change (%)
  • Year & Category slicers

3๏ธโƒฃ Product Insights Page

  • Top 10 Products by Revenue
  • Top 10 Products by Gross Profit
  • Detailed product table
  • Category / Subcategory slicers

4๏ธโƒฃ Returns Analysis Page

  • Return Rate % (KPI)
  • Return Rate by Category
  • Profitability vs Return Rate (Scatter Plot)
  • Return Details Table

๐Ÿงฎ Key DAX Measures

Total Revenue = SUM(public_vw_sales.revenue)

Total Gross Profit = SUM(public_vw_sales.gross_profit)

Profit Margin % =
DIVIDE([Total Gross Profit], [Total Revenue])

YoY Revenue % =
VAR CurrentYear = SELECTEDVALUE(public_vw_sales.year_)
VAR PrevYear = CurrentYear - 1
VAR CurrRevenue =
    CALCULATE([Total Revenue], public_vw_sales.year_ = CurrentYear)
VAR PrevRevenue =
    CALCULATE([Total Revenue], public_vw_sales.year_ = PrevYear)
RETURN
DIVIDE(CurrRevenue - PrevRevenue, PrevRevenue)


๐Ÿš€ How to Run This Project

You can either just explore the Power BI file, or fully recreate the backend in PostgreSQL.

โœ… Option 1 โ€“ Open the Power BI report only

  1. Download Retail-Sales-Analytics-Dashboard.pbix from this repository.
  2. Open it in Power BI Desktop.
  3. If the data connection fails:
    • You can view the existing visuals as-is, or
    • Re-point the data source to your own PostgreSQL / CSV files.

โœ… Option 2 โ€“ Rebuild the full SQL + Power BI pipeline

  1. Create a PostgreSQL database (for example):

    CREATE DATABASE retail_sales;
  2. Run the schema script to create all tables:

    schema.sql
  3. Load your data into:

    • calendar
    • dim_customer
    • dim_product_categories
    • dim_product_subcategories
    • dim_product
    • dim_territory
    • fact_sales
    • returns_data
  4. Create the main reporting view:

    view_vw_sales.sql

    This creates the vw_sales view that Power BI uses for most visuals.

  5. Connect Power BI to PostgreSQL:

    • In Power BI Desktop โ†’ Get data โ†’ PostgreSQL database
    • Server: your Postgres server (e.g. localhost)
    • Database: retail_sales
    • Select:
      • vw_sales
      • returns_data
    • Load the data and refresh the report.

Now you have the same data model and dashboards running end-to-end.


๐Ÿ“ธ Dashboard Screenshots

Here are the key pages from the Power BI dashboard included in this project.


๐Ÿ“Š 1๏ธโƒฃ Executive Summary

High-level KPIs and overview of revenue, profitability, and customer trends.

Executive Summary


๐Ÿ“ˆ 2๏ธโƒฃ Sales Trends

Monthly + yearly revenue trends, moving averages, and YoY analysis.

Sales Trends


๐Ÿ›’ 3๏ธโƒฃ Product Insights

Top products by revenue, gross profit, and category performance.

Product Insights


๐Ÿ”„ 4๏ธโƒฃ Returns Analysis

Return rate performance and profitability vs return rate.

Returns Analysis


๐Ÿ“ˆ Key Insights & Findings

A summary of the most important insights discovered in the analysis.

๐Ÿ”น 1. Sales Performance

  • Revenue consistently increased year-over-year, with the strongest growth in 2021.
  • The 3-month moving average shows stable seasonal patterns.
  • Bikes were the highest revenue-generating category across all years.

๐Ÿ”น 2. Product Insights

  • A small group of top products contributed the majority of revenue.
  • Products with higher profit margins were primarily in the Accessories and Components categories.
  • The Top 10% of customers generated a disproportionately large share of revenue.

๐Ÿ”น 3. Customer Insights

  • High-income customers showed the largest purchase volume.
  • Male and female customers had similar buying patterns, but male customers bought slightly higher-priced items.

๐Ÿ”น 4. Returns Analysis

  • Overall return rate was low (0โ€“3% for most categories).
  • A few specific products had unusually high return rates and may require quality review.
  • Some territories showed higher returns, indicating potential fulfillment or shipping issues.

๐Ÿ”น 5. Business Opportunities

  • Focusing marketing efforts on top revenue-generating customer segments can increase profitability.
  • Improving quality control on high-return products could reduce lost revenue.
  • Accessories and Components categories have high margins and should be promoted more.

๐Ÿ“ฌ Contact

Author: Shohag

If youโ€™d like to discuss this project, collaborate, or talk about data analyst roles:

About

A full end-to-end data analytics project using SQL, PostgreSQL, Power BI, DAX, and data modeling.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published