Chapter 6 — Power BI: Data Modeling & Relationships

📚 Chapter Overview

A great report is built on a solid data model. In this chapter, you will learn how to import data into Power BI, create relationships between tables (Star Schema), and write basic DAX formulas for custom calculations.

Learning Objectives:

6.1 The Star Schema

Part 1 — Definition

A Star Schema is an industry-standard way to organize data. It consists of one large Fact Table (containing numbers like sales) surrounded by several Dimension Tables (containing details like product info, dates, and locations). Connecting these tables is called "Modeling".

Part 2 — Relationship Types

Part 3 — Example

Problem: Connect a "Sales" table to a "Customer" table.

  1. Load both tables into Power BI Desktop.
  2. Go to the Model View.
  3. Drag customer_id from the Customer table to customer_id in the Sales table.

Observation: You can now filter Sales charts using Customer attributes like "Country" or "Gender".

Part 4 — Video

Video: Coming Soon


6.2 DAX Basics

Part 1 — Definition

DAX (Data Analysis Expressions) is the formula language for Power BI. It is similar to Excel formulas but much more powerful. You use DAX to create **Measures**, which are calculations that update dynamically as you filter your report.

Part 2 — Syntax

Total Sales = SUM(Sales[Revenue])
Profit Margin = DIVIDE([Profit], [Total Sales], 0)

Part 3 — Example

Problem: Calculate "Year-to-Date" (YTD) Sales.

Sales YTD = TOTALYTD(SUM(Sales[Amount]), 'Date'[Date])

Observation: Measures don't take up space in the file; they are calculated "on the fly" when you interact with the report.

Part 4 — Video

Video: Coming Soon


🏆 Chapter Challenge

Challenge Objective

Build a "Multi-Source Data Model".

Requirements

Step-by-Step Process

  1. Use "Get Data" for both sources.
  2. Verify the relationship line in Model View.
  3. Write the DAX formula.
  4. Drag the measure into a "Card" visual to verify the number.

Expected Deliverables