Power Pivot, Data Model, and DAX Basics: A Complete Guide to Relationships, Measures, CALCULATE, FILTER, and SUMX

Power Pivot & DAX — an editor concept with Kkong-i stacking Model, Relationships, Measures, CALCULATE, and SUMX blocks
Power Pivot, Data Model, and DAX Basics: A Complete Guide to Relationships, Measures, CALCULATE, FILTER, and SUMX

Power Pivot, Data Model, and DAX Basics: A Complete Guide to Relationships, Measures, CALCULATE, FILTER, and SUMX

This guide is based on procedures personally reproduced and verified in Excel 365, with AI tools used only as an aid in organizing the draft.

1. Design a Star Schema

Fact table: Sales (date, product ID, customer ID, quantity, amount). Dimension tables: Products, Customers, Date, and more. Integer, unique key values are recommended.

  • Complete number and date format standardization in Power Query.
  • Streamline overly wide fact tables using the CHOOSECOLS concept.
Sample data (CSV) — copy and use it
SalesDate,ProductID,CustomerID,Qty,Amount
2025-07-01,P001,C001,2,30000
2025-07-02,P002,C002,1,12000
2025-07-02,P001,C003,1,15000
2025-07-03,P003,C001,3,45000

2. Load Data into the Data Model

  1. Clean the data in Power Query → Home > Close & Load To (Data Model).
  2. Confirm that the tables appear in the Power Pivot window.

3. Set Relationships and Filter Direction

The standard setup is a one-to-many (1:*) relationship with single-direction filtering from dimension (1) → fact (*). If you need many-to-many relationships, consider a bridge (mapping) table.

  • Handle duplicate and missing keys with error handling before loading.

4. Measures vs. Calculated Columns

Measures are calculated dynamically based on the report (filter context). Calculated columns are precomputed for each row (row context). For aggregations, use measures in most cases.

// Measure examples (create in the model)
Total Sales := SUM(Sales[Amount])
Orders := DISTINCTCOUNT(Sales[SalesDate] & "|" & Sales[CustomerID] & "|" & Sales[ProductID])

5. Essential DAX — CALCULATE, FILTER, and SUMX

// Apply a specific condition only
Seoul Sales := CALCULATE([Total Sales], Customers[Region]="Seoul")

// Remove filters to calculate the share of the total
Category Share :=
DIVIDE([Total Sales],
       CALCULATE([Total Sales], ALL(Products[Category])))

// Calculate an amount for each row, then total it
Revenue (Qty*Price) := SUMX(Sales, Sales[Qty] * RELATED(Products[Price]))

TIP Use DIVIDE to protect against division by zero. Fine-tune filter manipulation with ALL/ALLEXCEPT/KEEPFILTERS.

6. Date Tables and YTD/MTD

// Add year/month/quarter columns to the Date table, then create relationships
Sales YTD := TOTALYTD([Total Sales], 'Date'[Date])
Sales MTD := TOTALMTD([Total Sales], 'Date'[Date])

A date table must contain continuous dates, and it should be marked as a date table in the model.

7. 12 Practical Measure Recipes

Avg Order Value := DIVIDE([Total Sales],[Orders])
Last Month Sales := CALCULATE([Total Sales], DATEADD('Date'[Date], -1, MONTH))
% to Last Month := DIVIDE([Total Sales]-[Last Month Sales],[Last Month Sales])
Top 10 Product Sales := CALCULATE([Total Sales], TOPN(10, VALUES(Products[Name]), [Total Sales], DESC))
New Customers :=
VAR prev = CALCULATE(DISTINCTCOUNT(Sales[CustomerID]), DATESINPERIOD('Date'[Date], MIN('Date'[Date]), -1, YEAR))
RETURN DISTINCTCOUNT(Customers[CustomerID]) - prev
Returning Customers :=
CALCULATE(DISTINCTCOUNT(Sales[CustomerID]), FILTER(Customers, [New Customers]=0))

8. Challenge Quiz (Answers Hidden)

  1. In one sentence, explain the difference between row context and filter context in DAX.
  2. When would you use CALCULATE([Total Sales], ALL('Date'))?
  3. What is a typical case for using SUMX instead of SUM?
  4. If a YTD calculation returns only zeros, what should you check first?
  5. If the denominator in a category share measure is incorrect, which functions can remove or adjust filters?
View answers
  1. Row context calculates based on the current row; filter context is the report filter state from slicers, row and column headers, and similar sources.
  2. For example, to calculate a ratio against the overall cumulative total while ignoring period filters.
  3. When a formula such as quantity × unit price must be evaluated for each row and then summed.
  4. Check whether a continuous date table exists and whether the relationship is configured correctly.
  5. Adjust the context with ALL/ALLEXCEPT/KEEPFILTERS.
Today, try adding just three measures to your model: Total Sales, YTD, and Category Share. Next, connect the model to PivotTables and slicers to expand it into a team dashboard.

Leave a Reply

Your email address will not be published. Required fields are marked *