๐ Power BI Amazon Sales Analysis: A Complete Guide with DAX Queries
In this tutorial, youโll learn how to build a full-fledged Power BI dashboard using Amazon-style marketplace data.
We’ll use sample data tables like Sellers, Products, Categories, and Sales
from multiple countries (Amazon USA, UK, UAE, India, KSA).
By the end, youโll master DAX queries, filters, relationships, and best practices for building dynamic and interactive Power BI reports.
๐งฉ Table of Contents
- Step 1: Understanding the Data Model
- Step 2: Creating the Excel Data Files
- Step 3: Importing into Power BI
- Step 4: Defining Relationships
- Step 5: Creating DAX Measures
- Step 6: Filtering and Slicing Data
- Step 7: Building Visuals and KPIs
- Step 8: Business Insights and Interpretation
- Step 9: Bonus Tips and Optimization
๐ Step 1: Understanding the Data Model
Before diving into Power BI, itโs important to understand how the tables relate to each other.
Hereโs our basic Amazon marketplace schema:
- Sellers: Contains seller ID, name, and country.
- Products: Product details including category and price.
- Categories: A simple lookup table of product categories.
- Sales: Includes product, seller, date, quantity, and country of sale.
Sellers Table:
โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโ
โ SellerID โ SellerName โ Country โ
โโโโโโโโโโโโผโโโโโโโโโโโโโโโโผโโโโโโโโโโโค
โ S001 โ Global Bazaar โ USA โ
โ S002 โ TechnoMart โ UK โ
โ ... โ ... โ ... โ
Products Table:
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโ
โ ProductID โ ProductName โ CategoryID โ Price โ
โโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโค
โ P001 โ Wireless Mouse โ C01 โ 25 โ
โ P002 โ USB Charger โ C02 โ 18 โ
Categories Table:
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโ
โ CategoryID โ CategoryName โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ C01 โ Electronics โ
โ C02 โ Mobile Accessories โ
Sales Table:
โโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโ
โ SaleID โ SaleDate โ ProductID โ SellerID โ Quantity โ Country โ
โโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโค
โ SL001 โ 2025-01-01 โ P001 โ S001 โ 5 โ USA โ
โ SL002 โ 2025-01-02 โ P002 โ S002 โ 2 โ UK โ
๐ฅ Step 2: Creating the Excel Data Files
Prepare four Excel sheets based on the structure above. You can download ready-to-use sample files below:
๐งฎ DAX Query Examples: From Single to Multi-Table Logic
Letโs walk through a series of DAX measures starting from simple single-table logic and progressing to multi-table relational queries involving Sales, Products, Categories, and Sellers.
โ 1. Total Quantity (Single Table)
Calculate the total quantity sold using only the Sales
table.
Total Quantity = SUM(Sales[Quantity])
โ 2. Total Sales (Flat Price โ Single Table)
Assuming every product has a flat price of 25 (not recommended in real cases).
Total Sales (Flat Price) = SUM(Sales[Quantity]) * 25
โ 3. Total Sales (Using Two Tables: Sales + Products)
Join Sales
and Products
using RELATED()
to fetch the product price.
Total Sales =
SUMX(
Sales,
Sales[Quantity] * RELATED(Products[Price])
)
โ 4. Sales by Product
Group total sales by ProductID. Use Products[ProductName]
in visuals.
Sales by Product =
CALCULATE(
[Total Sales],
ALLEXCEPT(Sales, Sales[ProductID])
)
โ 5. Sales by Category (Three Tables: Sales + Products + Categories)
To break sales down by CategoryName
, use RELATED()
and CALCULATE()
.
Sales by Category =
CALCULATE(
[Total Sales],
ALLEXCEPT(Products, Products[CategoryID])
)
Optional calculated column (if needed):
CategoryName = RELATED(Categories[CategoryName])
โ 6. Sales by Country (Four Tables)
Analyze sales based on the Country column in the Sales
table.
Sales by Country =
CALCULATE(
[Total Sales],
ALLEXCEPT(Sales, Sales[Country])
)
โ 7. Sales by Seller
Group revenue by SellerID
. Use Sellers[SellerName]
in the visual.
Sales by Seller =
CALCULATE(
[Total Sales],
ALLEXCEPT(Sales, Sales[SellerID])
)
โ 8. Combined Analysis: Seller + Country + Category
Once the model is fully related, you can use the base measure Total Sales
and apply it across multiple dimensions visually:
- Rows: Sellers[SellerName]
- Columns: Sales[Country]
- Filters/Slicers: Categories[CategoryName]
Total Sales =
SUMX(
Sales,
Sales[Quantity] * RELATED(Products[Price])
)
๐ Summary Table
Measure Name | DAX Formula Type | Description | Tables Used |
---|---|---|---|
Total Quantity | SUM | Basic quantity from Sales | Sales |
Total Sales (Flat) | SUM * Constant | Simulated pricing | Sales |
Total Sales | SUMX + RELATED | Revenue per product | Sales, Products |
Sales by Product | CALCULATE + ALLEXCEPT | Product-wise revenue | Sales, Products |
Sales by Category | CALCULATE + RELATED | Category-wise revenue | Sales, Products, Categories |
Sales by Country | ALLEXCEPT | Country-wise sales | Sales, Products, Categories, Sellers |
Sales by Seller | ALLEXCEPT | Revenue by SellerID | Sales, Sellers |
These are the foundational measures you’ll use for dashboards, KPIs, and category breakdowns in Power BI. As we progress, we can build more advanced logic with filters, dates, and ranking.
๐ Step 3: Importing into Power BI
Open Power BI Desktop and follow these steps:
- Click Get Data โ Choose Excel
- Load all four tables into Power BI
- Rename each table for consistency (e.g., tbl_Sellers, tbl_Products, etc.)
๐ Step 4: Defining Relationships
Go to the Model View and define relationships between the tables:
Sales[SellerID]
โSellers[SellerID]
Sales[ProductID]
โProducts[ProductID]
Products[CategoryID]
โCategories[CategoryID]
๐งฎ Step 5: Creating DAX Measures
Now, letโs write some essential DAX formulas in the Sales table:
Total Sales = SUMX(Sales, Sales[Quantity] * RELATED(Products[Price]))
Total Quantity = SUM(Sales[Quantity])
Sales by Country =
CALCULATE(
[Total Sales],
ALLEXCEPT(Sales, Sales[Country])
)
Revenue by Seller =
SUMX(
Sales,
Sales[Quantity] * RELATED(Products[Price])
)
๐ Step 6: Filtering and Slicing Data
Use slicers for:
- Country
- Product Category
- Sale Date (with between filter)
- Seller Name
Also create calculated columns like:
Month = FORMAT(Sales[SaleDate], "MMM YYYY")
๐ Step 7: Building Visuals and KPIs
Create these visuals in your report:
- Card: Total Sales
- Bar Chart: Sales by Country
- Line Chart: Monthly Sales Trend
- Table: Top 5 Sellers by Revenue
- Pie Chart: Sales by Category
๐ก Step 8: Business Insights and Interpretation
Ask key questions like:
- Which country generates the most revenue?
- Which product category performs best?
- Are sales increasing month-to-month?
- Which seller is the top performer?
Use bookmarks and drill-through features to add interactivity.
๐ Step 9: Bonus Tips and Optimization
- Use
SUMMARIZE
andCALCULATE
for advanced aggregation - Optimize model by hiding unnecessary columns
- Create reusable measures instead of calculated columns
- Use themes and design templates for consistent branding
๐ Conclusion
๐ง ย Understanding DAX Filtering Logic Step-by-Step
One of the most powerful features of DAX is its ability to manipulate filters dynamically using functions like CALCULATE()
, FILTER()
, ALL()
, and others.
Letโs break down how filtering works in DAX and how you can use it to write smarter, more flexible measures.
๐ฏ 1. Implicit vs Explicit Filters
Power BI visuals apply implicit filters based on slicers or axes. DAX can override or modify these using explicit filters inside a measure.
-- Example 1: Implicit Filter from Visual
Total Quantity = SUM(Sales[Quantity])
-- If a slicer filters "India", the measure only sums Indian rows
โ๏ธ 2. Using CALCULATE to Modify Filters
CALCULATE()
evaluates an expression in a modified filter context.
-- Total Sales for UK only, regardless of slicer
Sales UK Only =
CALCULATE(
SUMX(Sales, Sales[Quantity] * RELATED(Products[Price])),
Sales[Country] = "UK"
)
๐งผ 3. Removing Filters with ALL()
ALL()
removes filters from a column or table. Use it when you want to ignore slicers or make comparisons.
-- Sales percentage of total (ignoring slicers)
% of Total Sales =
DIVIDE(
[Total Sales],
CALCULATE([Total Sales], ALL(Sales))
)
๐ 4. Keeping Filters with ALLEXCEPT()
ALLEXCEPT()
removes all filters except the one(s) you specify.
-- Country-wise sales with all other filters removed
Sales by Country =
CALCULATE(
[Total Sales],
ALLEXCEPT(Sales, Sales[Country])
)
๐ 5. Custom Row Context with FILTER()
FILTER()
lets you define your own row filtering logic inside CALCULATE.
-- Sales for high-volume orders only
High Volume Sales =
CALCULATE(
[Total Sales],
FILTER(Sales, Sales[Quantity] > 10)
)
๐ซ 6. Removing Specific Filters with REMOVEFILTERS()
REMOVEFILTERS()
is a modern replacement for ALL when you want to be more readable.
-- Ignore Product Category filter
All Categories Sales =
CALCULATE(
[Total Sales],
REMOVEFILTERS(Categories[CategoryName])
)
๐ 7. Row Context vs Filter Context
Row context is when DAX evaluates row-by-row (e.g., calculated column). Filter context is what visuals or CALCULATE use.
-- Inside a visual table (filter context), this works:
Total Revenue =
SUMX(Sales, Sales[Quantity] * RELATED(Products[Price]))
But in a calculated column, you’d already be in a row context and wouldn’t need CALCULATE unless bridging tables.
๐ง 8. Nested CALCULATE and FILTER Use Case
-- Top-Selling Products Only
Top Products Sales =
CALCULATE(
[Total Sales],
FILTER(
Products,
[Total Sales] > 1000
)
)
This is useful in Top N analysis, dynamic thresholds, or category-level metrics.
โ Summary
- CALCULATE() modifies filter context
- FILTER() adds row-level filtering logic
- ALL() and REMOVEFILTERS() remove filters for comparisons
- ALLEXCEPT() keeps specific filters for grouped totals
- Know the difference between row context and filter context
Mastering DAX filter logic is the key to unlocking advanced reporting and analytics in Power BI.