DAY 17: Excel - Power Pivot & Data Modeling (DAX basics)
Learning Objectives: - Introduction to Power Pivot and data modeling - Create relationships between tables - Understand star schema design - Write basic DAX formulas - Build calculated columns and measures
Topics Covered (60 min):
1. Power Pivot Introduction - Enable Power Pivot add-in - Import multiple tables - Data Model vs regular worksheets - Benefits: handle millions of rows, relate tables
2. Table Relationships - One-to-many relationships - Primary key and foreign key - Create relationships in diagram view - Star schema: Fact table + Dimension tables - Example: Orders (Fact) → Customers, Products, Dates (Dimensions)
3. DAX Basics - Calculated Columns
- DAX = Data Analysis Expressions
- Similar to Excel formulas but for tables
- Example: Profit = [Revenue] - [Cost]
- Calculated once when data refreshes
- Table[Column] reference syntax
4. DAX Measures
- Dynamic calculations (recalculate based on filters)
- Aggregation functions: SUM, AVERAGE, COUNT, etc.
- Example: Total Sales = SUM(Orders[Sales])
- Use in PivotTables with slicers
- Measures vs Calculated Columns
Video Resources:
Learn Excel What-If Analysis (17:39)
https://www.youtube.com/watch?v=mQceaaPuQe8What-If Analysis (Goal Seek, Scenario Manager, Data Table) (13:37)
https://www.youtube.com/watch?v=V4STN2DPVc8Excel What-If Analysis Data Table (14:20)
https://www.youtube.com/watch?v=4VuO1lO6USo
AI Learning Prompts (Concept Understanding Only):
Understanding Power Pivot:
I'm learning Power Pivot and data modeling. Please explain:
1. What is Power Pivot and how is it different from regular Excel?
2. What is a data model and why create relationships between tables?
3. Explain star schema design (fact and dimension tables)
4. How do I create a relationship between Orders and Customers tables?
5. Provide a beginner-friendly example using sales data
Use simple examples to explain the concepts.
Understanding DAX:
Help me understand DAX formulas:
1. What is DAX and how is it different from Excel formulas?
2. What is the difference between calculated columns and measures?
3. Show me basic DAX formulas: SUM, AVERAGE, COUNT
4. How do I reference columns from different tables?
5. Provide examples creating Total Sales, Average Price, Profit measures
Explain with practical scenarios.
Guided Practice (60 min):
📝 How to approach Guided Practice:
- Follow step-by-step: Work through each exercise in order
- Use provided resources: Reference the video tutorials and AI prompts if you get stuck
- Verify your work: Check your results match expected outcomes
- Take notes: Document key learnings and shortcuts you discover
- Ask for help: Use AI assistants to clarify concepts you don't understand
Exercise 1: Enable Power Pivot and Load Data into Data Model
Goal: Learn to activate Power Pivot and import tables into the Excel Data Model.
Step-by-Step Instructions:
- Enable Power Pivot: File → Options → Add-ins → Manage: COM Add-ins → Go → Check "Microsoft Power Pivot" → OK
- Verify Power Pivot tab: You should see a new "Power Pivot" tab in the ribbon
- Prepare your data: Have 3 worksheets ready - Orders (OrderID, CustomerID, ProductID, Sales, OrderDate), Customers (CustomerID, Name, City), Products (ProductID, Name, Category)
- Load Orders table: Select any cell in Orders data → Power Pivot tab → Add to Data Model
- Repeat for other tables: Load Customers and Products tables to Data Model
- View in Power Pivot window: Power Pivot → Manage → You'll see all three tables loaded
💡 Tips:
- Power Pivot vs regular Excel: Power Pivot handles millions of rows, regular Excel limited to ~1M rows
- Table names: Excel converts ranges to proper tables automatically when loading to Data Model
- Data Model is in-memory: Faster than worksheet calculations for large datasets
- No duplicate checking: Power Pivot doesn't prevent duplicate IDs - ensure data quality first
- Keyboard shortcut: Alt+B+M opens Manage Data Model
✅ Expected Result: Three tables visible in Power Pivot window, ready for relationships
Exercise 2: Create Relationships Between Tables (Star Schema)
Goal: Build a star schema by creating relationships between fact (Orders) and dimension tables (Customers, Products).
Step-by-Step Instructions:
- In Power Pivot window: Click Home → Diagram View (or click diagram icon)
- Understand the layout: Orders is your fact table (center), Customers and Products are dimension tables
- Create Orders-Customers relationship: Drag CustomerID from Orders table to CustomerID in Customers table
- Create Orders-Products relationship: Drag ProductID from Orders to ProductID in Products
- Verify relationships: You'll see lines connecting tables with "1" (one) and "*" (many) indicators
- Check relationship details: Double-click any relationship line to see properties (should be 1-to-many)
💡 Tips:
- One-to-many relationships: One customer → many orders, one product → many orders
- Primary/Foreign keys: Dimension table IDs are primary keys (unique), fact table IDs are foreign keys
- Auto-detect: Power Pivot sometimes auto-detects relationships based on column names
- Relationship direction: Filters flow from dimension to fact table (one-way by default)
- Star schema benefits: Organized, performant, matches how business thinks about data
✅ Expected Result: Diagram showing Orders in center connected to Customers and Products, with 1:* relationships
Exercise 3: Create Calculated Columns with DAX
Goal: Add calculated columns to your tables using DAX formulas.
Step-by-Step Instructions:
- In Power Pivot window: Switch to Data View (grid icon)
- Click Orders table
- Add Profit column: Click in "Add Column" header → Type:
=Orders[Sales] - Orders[Cost]→ Enter - Rename the column: Right-click column header → Rename → Type "Profit"
- Add Profit Margin %: New column →
=Orders[Profit] / Orders[Sales]→ Format as Percentage - Add Year column:
=YEAR(Orders[OrderDate])→ Rename to "OrderYear"
💡 Tips:
- DAX vs Excel formulas: DAX is column-based (operates on entire columns), Excel is cell-based
- Table[Column] syntax: Always reference columns as TableName[ColumnName]
- Calculated columns vs measures: Calculated columns store values in model, measures calculate on-the-fly
- When to use calculated columns: When you need to filter or slice by the calculated value
- Performance: Calculated columns increase model size, use sparingly for large datasets
✅ Expected Result: Orders table has three new columns: Profit, Profit Margin %, OrderYear with calculated values
Exercise 4: Create DAX Measures for Analysis
Goal: Write DAX measures for dynamic calculations in Pivot Tables.
Step-by-Step Instructions:
- In Power Pivot: Click Orders table → Home → New Measure (or click in measure grid at bottom)
- Create Total Sales measure: Measure Name: "Total Sales" | Formula:
=SUM(Orders[Sales])→ OK - Create Total Profit: New Measure → Name: "Total Profit" | Formula:
=SUM(Orders[Profit]) - Create Average Order Value:
=AVERAGE(Orders[Sales]) - Create Customer Count:
=DISTINCTCOUNT(Orders[CustomerID]) - Create Profit Margin %:
=[Total Profit] / [Total Sales](references other measures!)
💡 Tips:
- Measures vs Calculated Columns: Measures don't store data, calculate based on pivot table context
- Measure syntax: No table prefix needed:
=SUM(Orders[Sales])or=[Total Sales]for measure references - Context matters: Same measure shows different values based on rows/columns in pivot table
- Best practice: Use measures for aggregations (SUM, AVG, COUNT), calculated columns for row-level logic
- Format measures: Right-click measure → Format → Choose currency, percentage, etc.
✅ Expected Result: Five measures visible in field list, ready to drag into pivot tables
Exercise 5: Build Pivot Table Using Data Model and Measures
Goal: Create a pivot table that uses your relationships and measures for analysis.
Step-by-Step Instructions:
- Return to Excel worksheet: Close Power Pivot window
- Insert Pivot Table: Insert tab → PivotTable → Use this workbook's Data Model → OK
- In PivotTable Fields: You'll see all tables with expand arrows
- Add rows: Drag Products[Category] to Rows area
- Add measures: Drag "Total Sales", "Total Profit", "Profit Margin %" to Values area
- Add slicer for Year: Expand Orders table → Right-click OrderYear → Add as Slicer
- Add slicer for City: From Customers table → Right-click City → Add as Slicer
- Test interactivity: Click different years/cities and watch measures update
💡 Tips:
- Data Model pivot tables are different: Can use fields from multiple tables due to relationships
- Measures vs regular fields: Measures show ∑ icon, regular fields show different icons
- Slicers filter all: Slicers work across all tables when relationships are correct
- Cannot change values: Data Model pivot tables are read-only (can't double-click to drill to detail)
- Advanced features: Use Analyze tab → Fields, Items, & Sets for advanced layouts
✅ Expected Result: Interactive pivot table showing sales/profit by category, filterable by year and city using slicers
🔄 Connection to SQL: Power Pivot relationships are like SQL JOINs, and DAX measures are like SQL aggregate functions with GROUP BY!
Independent Practice (60 min):
💡 Hints for Independent Practice:
- Start simple: Begin with basic variations before attempting complex modifications
- Break it down: Divide complex problems into smaller, manageable steps
- Test incrementally: Verify each step works before moving to the next
- Use documentation: Refer to official docs or tutorials when needed
- Experiment: Try different approaches to find what works best
Apply the concepts learned to different datasets and scenarios.
Daily Assignment (60 min):
Assignment:
- Import Tables:Load Orders, Customers, Products, Dates tables
- Create Relationships:Build star schema (Orders as fact table)
- Calculated Columns:Add Profit, Margin%, Days to Ship columns using DAX
- DAX Measures:Create Total Sales, Total Profit, Avg Order Value, Customer Count measures
- PivotTable:Build dashboard using measures with slicers for Category, Region, Year
Expected Outcomes:
- Introduction to Power Pivot and data modeling
- Create relationships between tables
- Understand star schema design
- Write basic DAX formulas
- Build calculated columns and measures
📝 Day 17 Quick Quiz - Test Your Knowledge!
Q1. What is the primary focus of Day 17?
Q2. Which skill from Day 17 is most valuable for business analysis?
Q3. How does Day 17 build on previous lessons?
Q4. What type of problems does Day 17 help solve?
Q5. What's the best way to practice Day 17 skills?