Back to projects
CASE STUDY 02 · SALES ANALYTICS

Retail Sales Analytics

Historical sales, cost, and gross margin analysis with PostgreSQL, SQL, and Power BI, from metric calculations to the final dashboard.

PostgreSQLSQLPower BI

Historical sales case study (2016–2021). Amounts are estimates based on catalog prices and costs expressed in USD.

US$55.76MEstimated revenue
US$23.09MEstimated costs
US$32.66MEstimated gross profit
58.58%Gross margin

Figures rounded for display. The SQL query also validated 26,329 orders and 197,907 units.

01 / CONTEXT

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.

02 / METHOD

From transactions to insights

01

Data preparation and validation

Organized sales, products, customers, and stores in PostgreSQL, reviewing keys, quantities, and dates relevant to the calculations.

02

Commercial SQL calculations

Joined sales and products with INNER JOIN and calculated estimated revenue and costs using quantities and unit prices/costs in USD.

03

Data modeling

Linked the clean_sales fact table to product, customer, store, and calendar dimensions using one-to-many relationships.

04

Power BI reporting

Dashboard featuring revenue, costs, and margin KPIs, slicers for year/category/channel, and charts for categories, products, monthly trends, and channels.

03 / EVIDENCE

Evidence of the workflow

Screenshots of the Power BI data model and a PostgreSQL query with results. Select any image to enlarge it.

04 / OUTCOME

Final Power BI dashboard

Explore revenue, costs, margins, and commercial distribution using year, category, and channel filters. A full screenshot is available for now.

Retail Sales Analytics

Interactive dashboard

Explore revenue, costs, gross margin, and commercial performance with interactive filters.

Open dashboard in Power BI
05 / FINDINGS

Key findings

US$19.3M

Computers leads revenue

Computers contributes the most estimated revenue, followed by Home Appliances at approximately US$10.8M.

79.55%

Physical stores dominate

Physical stores account for about 79.55% of estimated revenue, versus 20.45% from the online channel.

58.58%

Estimated gross margin

The estimated revenue-cost difference yields US$32.66M in gross profit according to the project's calculations.

26,329

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.