Skip to content

Latest commit

ย 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Š ProfitLens โ€” Retail Profitability & Revenue Leakage Analytics

An end-to-end data analytics project that transforms raw retail transaction data into actionable insights on profitability, customer performance, product performance, regional performance, and returns & refunds.

Status SQL Python Power BI


๐Ÿ“Œ Project Overview

ProfitLens is an end-to-end retail analytics project built to answer a fundamental business question:

Where is the business generating revenue but failing to maximize profitability, and what actions can management take to improve financial performance?

The project combines SQL, Python, and Power BI to move from raw transactional data โ†’ data cleaning โ†’ exploratory analysis โ†’ profitability analysis โ†’ interactive dashboards โ†’ management recommendations.

Rather than focusing only on sales volume, ProfitLens evaluates performance through the lens of revenue, gross profit, profit margin, customer contribution, product contribution, regional performance, and refund/return exposure โ€” the metrics that actually determine whether growth is healthy.


๐ŸŽฏ Business Problem

Strong revenue does not automatically mean strong business performance. A retail business can post impressive sales while quietly bleeding profitability because of:

  • Low-margin products propping up top-line revenue
  • Unprofitable or marginal customer segments
  • Regional performance gaps hidden inside national averages
  • A product mix skewed toward volume over margin
  • High refund/return exposure eating into net revenue
  • Revenue concentration risk (too much reliance on a few customers/products)
  • High-revenue customer segments that may not translate proportionally into gross profit

ProfitLens investigates each of these areas to pinpoint where management attention would create the greatest financial impact โ€” and backs every recommendation with the underlying data.


๐Ÿ”Ž Key Business Questions

๐Ÿ’ฐ Revenue & Sales

  • Which products generate the most revenue?
  • Which customers contribute the most revenue?
  • Which categories drive revenue?
  • How is revenue distributed across the business?

๐Ÿ“ˆ Profitability

  • Which products generate the highest gross profit?
  • Which categories contribute the most profit?
  • Which customers generate high revenue but relatively lower profitability?
  • Which states/regions contribute the most gross profit?
  • How does revenue compare with gross profit margin across segments?

๐Ÿ‘ฅ Customer Performance

  • Which customers are the largest revenue contributors?
  • Which customers generate the highest profit?
  • Which high-revenue customers have comparatively lower margins (i.e., where is revenue quality weakest)?

โ†ฉ๏ธ Returns & Refunds

  • How much revenue is exposed to refunds?
  • Which categories generate the highest refund amounts?
  • Which products have the highest refund exposure?
  • Which states contribute the highest refund amounts?
  • What is the refund rate across categories?

๐Ÿ—๏ธ Project Architecture

                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚      Raw Transactional      โ”‚
                    โ”‚            Data             โ”‚
                    โ”‚  Orders โ€ข Customers โ€ข       โ”‚
                    โ”‚  Products โ€ข Returns โ€ข etc.  โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                   โ”‚
                                   โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚       SQL Data Layer        โ”‚
                    โ”‚                             โ”‚
                    โ”‚  โ€ข Data Cleaning            โ”‚
                    โ”‚  โ€ข Data Validation          โ”‚
                    โ”‚  โ€ข Business Analysis        โ”‚
                    โ”‚  โ€ข CTEs / Window Functions  โ”‚
                    โ”‚  โ€ข Aggregations & Ranking   โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                   โ”‚
                                   โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚      Cleaned Dataset        โ”‚
                    โ”‚                             โ”‚
                    โ”‚   order_item_cleaned.csv    โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                   โ”‚
                                   โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚      Python Analytics       โ”‚
                    โ”‚                             โ”‚
                    โ”‚  โ€ข Data Inspection          โ”‚
                    โ”‚  โ€ข Exploratory Data Analysisโ”‚
                    โ”‚  โ€ข Profitability Analysis   โ”‚
                    โ”‚  โ€ข Return & Refund Analysis โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                   โ”‚
                                   โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚      Business Insights      โ”‚
                    โ”‚                             โ”‚
                    โ”‚  Revenue โ€ข Profitability    โ”‚
                    โ”‚  Customers โ€ข Products       โ”‚
                    โ”‚  Regions โ€ข Refunds          โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                   โ”‚
                                   โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚       Power BI Layer        โ”‚
                    โ”‚                             โ”‚
                    โ”‚  โ€ข Data Modeling            โ”‚
                    โ”‚  โ€ข DAX Measures             โ”‚
                    โ”‚  โ€ข KPI Development          โ”‚
                    โ”‚  โ€ข Interactive Dashboards   โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                   โ”‚
                                   โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚      Decision Support       โ”‚
                    โ”‚                             โ”‚
                    โ”‚  Executive Summary          โ”‚
                    โ”‚  Business Recommendations   โ”‚
                    โ”‚  Actionable Insights        โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Tech Stack

Layer Tools Used
Database SQL (schema design, CTEs, window functions, joins)
Data Cleaning & EDA Python (Pandas, NumPy)
Visualization (EDA) Matplotlib, Seaborn
Business Intelligence Power BI (DAX, Power Query, data modeling)
Version Control Git & GitHub
Environment Jupyter Notebook

๐Ÿ“ Repository Structure

ProfitLens/
โ”‚
โ”œโ”€โ”€ 01_documentation/
โ”‚   โ”œโ”€โ”€ 01_requirements.txt
โ”‚   โ””โ”€โ”€ 02_ProfitLens_Project_Documentation.pdf
โ”‚
โ”œโ”€โ”€ 02_data/
โ”‚   โ”œโ”€โ”€ cleaned_data/
โ”‚   โ”‚   โ””โ”€โ”€ order_item_cleaned.csv
โ”‚   โ””โ”€โ”€ raw_data/
โ”‚       โ”œโ”€โ”€ categories.csv
โ”‚       โ”œโ”€โ”€ customers.csv
โ”‚       โ”œโ”€โ”€ order_items.csv
โ”‚       โ”œโ”€โ”€ orders.csv
โ”‚       โ”œโ”€โ”€ products.csv
โ”‚       โ””โ”€โ”€ returns.csv
โ”‚
โ”œโ”€โ”€ 03_sql/
โ”‚   โ”œโ”€โ”€ 01_data_cleaning.sql
โ”‚   โ””โ”€โ”€ 02_business_analysis.sql
โ”‚
โ”œโ”€โ”€ 04_python/
โ”‚   โ”œโ”€โ”€ 01_data_inspection.ipynb
โ”‚   โ”œโ”€โ”€ 02_EDA.ipynb
โ”‚   โ”œโ”€โ”€ 03_profitability_analysis.ipynb
โ”‚   โ””โ”€โ”€ 04_return_&_refund_analysis.ipynb
โ”‚
โ”œโ”€โ”€ 05_powerbi/
โ”‚   โ””โ”€โ”€ ProfitLens_Dashboard.pbix
โ”‚
โ”œโ”€โ”€ 06_reports/
โ”‚   โ”œโ”€โ”€ 01_ProfitLens_Executive_Summary_PDF.pdf
โ”‚   โ””โ”€โ”€ 02_ProfitLens_Business_Recommendation.pdf
โ”‚
โ”œโ”€โ”€ 07_visuals/
โ”‚   โ”œโ”€โ”€ 01_Executive_Overview_Dashboard.png
โ”‚   โ”œโ”€โ”€ 02_Product_Customer_Profitability_Dashboard.png
โ”‚   โ””โ”€โ”€ 03_Return_Refund_Dashboard.png
โ”‚
โ”œโ”€โ”€ 08_additional_resources/
โ”‚
โ”œโ”€โ”€ .gitignore
โ””โ”€โ”€ README.md

๐Ÿงฎ Methodology

  1. Data Cleaning (SQL) โ€” Standardized formats, handled nulls/duplicates, and validated referential integrity across orders, customers, products, and returns tables.
  2. Business Analysis (SQL) โ€” Used CTEs and window functions to calculate revenue, gross profit, margins, and ranked contribution by customer/product/region.
  3. Exploratory Data Analysis (Python) โ€” Profiled distributions, outliers, and correlations across revenue, profit, and refund variables.
  4. Profitability & Return Analysis (Python) โ€” Isolated high-revenue/low-margin segments and quantified refund exposure by category, product, and state.
  5. Dashboarding (Power BI) โ€” Built a connected data model with DAX measures for revenue, gross margin %, refund rate, and customer contribution, surfaced through interactive drill-down dashboards.

๐Ÿ“Š Key Insights

  • ๐Ÿ’ก The top 10 customers by revenue account for only 1.22% of total revenue, indicating that revenue is highly diversified rather than concentrated among a small group of customers. However, the analysis does not calculate the corresponding gross-profit share for these customers.

  • ๐Ÿ’ก Bluetooth Speaker is a relatively low-margin product, generating approximately โ‚น9.67M (0.75%) of total revenue while carrying a gross margin of only 21.43%, below the overall business gross margin of 25.51%. A second Bluetooth Speaker SKU shows a similarly weak 23.27% margin.

  • ๐Ÿ’ก Bihar contributes the highest gross profit at approximately โ‚น14.47 Cr, or 4.41% of total gross profit. Uttarakhand underperforms with approximately โ‚น35.50M revenue and โ‚น8.82M gross profit, compared with Karnataka's โ‚น36.60M revenue and โ‚น9.35M gross profit, indicating weaker profit generation despite comparable revenue.

  • ๐Ÿ’ก Apparel/Fashion accounts for approximately 19.53% of total refund value while representing only 17.93% of units sold, indicating disproportionate refund exposure relative to its sales volume. Toys has the highest absolute refund value at โ‚น26.16M, representing 20.37% of total refunds.

  • ๐Ÿ’ก Overall refund exposure stands at 9.99% of gross revenue, translating to approximately โ‚น128.39M (โ‚น12.84 Cr) in refunded revenue. The analysis also records a 13.06% order return rate, making refunds a material profitability concern.


๐Ÿ“ˆ Dashboard Preview

ProfitLens Executive Overview Dashboard

The dashboard includes:

  • Executive Summary โ€” Revenue, gross profit, margin %, and refund rate at a glance
  • Product Performance โ€” Revenue vs. margin by product/category
  • Customer Performance โ€” Top customers by revenue vs. profit contribution
  • Regional Performance โ€” State-wise revenue and profitability heatmap
  • Returns & Refunds โ€” Refund exposure by category, product, and region

โœ… Business Recommendations

Based on the analysis, ProfitLens surfaces the following data-backed recommendations:

  1. Re-evaluate pricing and sourcing for low-margin products โ€” Products such as Bluetooth Speaker generate meaningful revenue but operate below the 25.51% overall gross margin, indicating an opportunity to improve supplier costs, pricing, or promotional strategy without sacrificing sales volume.

  2. Prioritize profitability over revenue alone in product decisions โ€” Management should evaluate products using revenue, gross margin, and gross-profit contribution together, rather than prioritizing high-revenue products that may contribute disproportionately less profit.

  3. Investigate refund drivers in high-exposure categories โ€” Apparel/Fashion generates 19.53% of total refund value despite representing only 17.93% of units sold, while Toys contributes the highest absolute refund value at โ‚น26.16M. These categories should be investigated for product quality, sizing/specification issues, fulfillment accuracy, and customer-expectation gaps.

  4. Reduce refund-related revenue leakage โ€” With refunds representing approximately 9.99% of gross revenue (โ‚น128.39M / โ‚น12.84 Cr) and an overall 13.06% order return rate, the business should establish category-level return KPIs and conduct root-cause analysis to reduce avoidable refunds.

  5. Optimize regional sales and profitability strategy โ€” Bihar is the strongest gross-profit contributor, while regions such as Uttarakhand generate revenue comparable to Karnataka but produce slightly weaker gross-profit outcomes. Regional strategies should therefore be evaluated on profitability and margin quality, not revenue alone.

  6. Maintain a diversified customer base while monitoring account profitability โ€” The top 10 customers contribute only 1.22% of total revenue, suggesting low customer-concentration risk. However, customer-level gross-profit contribution should be incorporated into account management to identify customers who generate revenue but deliver weaker margins.

  7. Shift commercial focus toward sustainable profit growth Commercial resources should prioritize:

  • High-margin products
  • Profitable regions
  • Lower-refund categories
  • Strong gross-profit contributors

Low-margin and high-refund segments should be managed through targeted pricing, sourcing, product, and operational interventions.

The goal is not simply to maximize revenue, but to improve the quality and sustainability of revenue growth.


๐Ÿš€ How to Run This Project

1. Clone the Repository

git clone https://github.com/ak-dataanalytics/ProfitLens.git
cd ProfitLens

2. Review the Documentation

Project requirements and supporting documentation are available in:

01_documentation/

3. Set Up the SQL Database

Open the SQL scripts from:

03_sql/

Run the scripts in the following order:

01_data_cleaning.sql
        โ†“
02_business_analysis.sql

Make sure the database connection, database name, and table names match your local SQL Server environment.

4. Set Up the Python Environment

Install the required dependencies:

pip install -r 01_documentation/01_requirements.txt

Launch Jupyter Notebook:

jupyter notebook

Run the notebooks from:

04_python/

in the following order:

01_data_inspection.ipynb
        โ†“
02_EDA.ipynb
        โ†“
03_profitability_analysis.ipynb
        โ†“
04_return_&_refund_analysis.ipynb

5. Open the Power BI Dashboard

Open:

05_powerbi/ProfitLens_Dashboard.pbix

using Power BI Desktop.

If required, update the local SQL Server/database connection and refresh the data model.

๐Ÿง  Skills Demonstrated

  • SQL: CTEs, window functions, joins, aggregate business logic
  • Python: data cleaning, EDA, statistical summarization (Pandas, NumPy)
  • Data visualization: Matplotlib, Seaborn
  • Business intelligence: Power BI data modeling and DAX
  • Business acumen: translating raw metrics into profitability-focused insight and recommendations

๐Ÿ”ฎ Future Enhancements

  • Add time-series/trend analysis of revenue and margin over time
  • Build a customer segmentation model (RFM or clustering) to complement the profitability view
  • Automate the SQL โ†’ Python โ†’ Power BI refresh pipeline

๐Ÿ‘ค Author

Aditya Kumar

Data Analyst | SQL | Python | Power BI | Excel | Business Intelligence

๐Ÿ“ง Email: adityakrr02@gmail.com
๐Ÿ”— LinkedIn: https://linkedin.com/in/xaditya
๐Ÿ’ป GitHub: https://github.com/ak-dataanalytics

If you found this project useful or interesting, consider โญ starring the repo!

About

`End-to-end retail sales analytics project using SQL, Python, and Power BI to analyze profitability, customer performance, and returns & refunds.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages