Retail Sales Analytics
Historical sales, cost, and gross margin analysis with PostgreSQL, SQL, and Power BI, from metric calculations to the final dashboard.
Historical sales case study (2016–2021). Amounts are estimates based on catalog prices and costs expressed in USD.
Figures rounded for display. The SQL query also validated 26,329 orders and 197,907 units.
The business question and goal
Understanding sales across products and channels requires connecting transactions to product, customer, and store data. Without comparable measures, finding the largest contributors and assessing profitability becomes difficult.
Build an analytics solution to explore estimated revenue, costs, gross margin, categories, products, sales channels, and trends over time.
From transactions to insights
Data preparation and validation
Organized sales, products, customers, and stores in PostgreSQL, reviewing keys, quantities, and dates relevant to the calculations.
Commercial SQL calculations
Joined sales and products with INNER JOIN and calculated estimated revenue and costs using quantities and unit prices/costs in USD.
Data modeling
Linked the clean_sales fact table to product, customer, store, and calendar dimensions using one-to-many relationships.
Power BI reporting
Dashboard featuring revenue, costs, and margin KPIs, slicers for year/category/channel, and charts for categories, products, monthly trends, and channels.
Evidence of the workflow
Screenshots of the Power BI data model and a PostgreSQL query with results. Select any image to enlarge it.
Final Power BI dashboard
Explore revenue, costs, margins, and commercial distribution using year, category, and channel filters. A full screenshot is available for now.
Key findings
Computers leads revenue
Computers contributes the most estimated revenue, followed by Home Appliances at approximately US$10.8M.
Physical stores dominate
Physical stores account for about 79.55% of estimated revenue, versus 20.45% from the online channel.
Estimated gross margin
The estimated revenue-cost difference yields US$32.66M in gross profit according to the project's calculations.
Validated unique orders
The SQL query returns 26,329 orders and 197,907 units, and its monetary totals match the Power BI KPIs.
Commercial analysis opportunities
- Compare category margins, not only revenue.
- Investigate performance differences between physical and online channels.
- Explore revenue concentration among top products and trends over time.
Skills demonstrated
PostgreSQL SQL queries, KPI validation, dimensional modeling, profitability analysis, and communicating findings with Power BI.