Popular Searches
Popular Course Categories
Popular Courses

Designing Fact Tables and Dimension Tables

Designing Fact Tables and Dimension Tables

Data Modeling and Relationships

Designing Fact Tables and Dimension Tables in Power BI

Course: Microsoft Power BI Training

Topic: Designing Fact Tables and Dimension Tables

Course Link: Microsoft Power BI Training – JustAcademy

Demo Link: Register for a Course Demo

JustAcademy Website: Visit JustAcademy


1. Introduction to Fact Tables and Dimension Tables

Data modeling is one of the most important stages of developing an effective Power BI solution. A well-designed data model helps users analyze business performance, calculate meaningful metrics, filter information accurately, and build interactive reports.

In real-world business environments, information is usually stored across multiple tables, databases, spreadsheets, and enterprise systems. Instead of combining every piece of information into a single large table, Power BI developers organize data into different table types based on their purpose.

The two fundamental table types in dimensional modeling are:

  • Fact Tables: Store business events, transactions, measurements, and numeric values that can be analyzed.
  • Dimension Tables: Store descriptive information that provides context for analyzing facts.

For example, an online store may have a Sales fact table containing transaction amounts and quantities. Separate Customer, Product, Date, and Region dimension tables provide descriptive details that users can use to analyze sales.

These tables are commonly organized using a star schema, a dimensional modeling approach that makes reporting and analysis easier to understand.

2. Learning Objectives

After completing this topic, learners should be able to:

  • Understand the purpose of fact tables and dimension tables.
  • Identify the grain of a fact table.
  • Distinguish between transactional facts, descriptive attributes, and measures.
  • Design fact tables with appropriate keys and numeric columns.
  • Design dimension tables with unique identifiers and descriptive attributes.
  • Understand the structure and benefits of a star schema.
  • Create one-to-many relationships between dimensions and facts.
  • Understand additive, semi-additive, and non-additive measures.
  • Recognize common dimensional modeling mistakes.
  • Apply fact and dimension table design principles in practical Power BI projects.

3. Understanding Fact Tables

3.1 What Is a Fact Table?

A fact table is a central table in a dimensional data model that records measurable business events or observations. It generally contains foreign keys that connect to dimension tables and numeric columns that describe the event.

Examples of business events include:

  • A customer purchasing a product.
  • A company receiving a payment.
  • An employee recording working hours.
  • A warehouse receiving inventory.
  • A customer placing an order.
  • A bank recording a financial transaction.

Each row in a fact table represents an event or observation at a defined level of detail, known as the grain.

3.2 Example of a Sales Fact Table

SalesKey DateKey CustomerKey ProductKey Quantity UnitPrice SalesAmount
1001 20260101 101 201 2 500 1000
1002 20260102 102 202 1 800 800
1003 20260102 101 203 3 200 600
1004 20260103 103 201 1 500 500

This table records individual sales transactions. Each row contains keys for connecting the transaction to the appropriate date, customer, and product, along with values that can be analyzed.

3.3 Common Columns in a Fact Table

Column Type Purpose Example
Fact Identifier Identifies a transaction or fact row when needed. SalesKey
Foreign Keys Connect the fact table to dimensions. DateKey, CustomerKey, ProductKey
Numeric Measures Store measurable business values. SalesAmount, Quantity
Transaction Attributes Store additional details about an event when appropriate. OrderNumber, TransactionType
Degenerate Dimensions Store useful identifiers directly in the fact table without a separate dimension. InvoiceNumber, OrderNumber

Not every fact table requires a separate fact identifier. Some tables can be uniquely identified using a combination of their foreign keys and other transaction-level attributes.

3.4 Characteristics of Fact Tables

  • Usually contain many rows.
  • Record business events at a defined grain.
  • Contain foreign keys to relevant dimensions.
  • Often contain numeric measures.
  • May receive new records frequently as business events occur.
  • Are used for aggregations, calculations, and trend analysis.
  • Can represent transactions, periodic snapshots, or accumulating business processes.

4. Understanding Dimension Tables

4.1 What Is a Dimension Table?

A dimension table contains descriptive attributes that explain the entities involved in business events. Dimension tables allow users to group, filter, label, and compare the values stored in fact tables.

Common dimension tables include:

  • Customers.
  • Products.
  • Dates.
  • Employees.
  • Locations.
  • Departments.
  • Suppliers.
  • Sales territories.

4.2 Example of a Customer Dimension Table

CustomerKey CustomerID CustomerName City State CustomerSegment
101 C001 Rahul Sharma Mumbai Maharashtra Premium
102 C002 Priya Patel Pune Maharashtra Standard
103 C003 Amit Verma Delhi Delhi Premium

This table describes customers using attributes such as name, city, state, and customer segment. These attributes allow sales to be analyzed by customer location or customer category.

4.3 Common Columns in a Dimension Table

Column Type Purpose Example
Dimension Key Uniquely identifies a dimension record. CustomerKey
Business Key Identifies the entity in the source business system. CustomerID
Descriptive Attributes Describe the entity. CustomerName
Geographical Attributes Provide location information. City, State, Country
Classification Attributes Support grouping and categorization. CustomerSegment
Historical Attributes Track changes over time when required. EffectiveStartDate, EffectiveEndDate

4.4 Characteristics of Dimension Tables

  • Usually contain fewer rows than large transactional fact tables.
  • Contain descriptive text and classification attributes.
  • Typically have a unique key for each dimension record.
  • Support filtering and grouping in reports.
  • Can contain hierarchies, such as Country, State, and City.
  • May change when business entities are updated.
  • Can include historical versions of records when historical reporting requires them.

5. Fact Tables vs. Dimension Tables

Feature Fact Table Dimension Table
Main Purpose Records measurable business events. Describes business entities and provides context.
Typical Data Quantities, amounts, counts, foreign keys. Names, categories, locations, descriptions.
Example Sales Customers
Number of Rows Often large. Often smaller.
Keys Usually contains dimension foreign keys. Usually contains a unique dimension key.
Typical Operations Summing, counting, averaging, calculating ratios. Filtering, grouping, categorizing, slicing.
Example Question How much revenue was generated? Which customer segment generated the revenue?
Model Role Central measurement table. Descriptive table connected to facts.

6. Understanding Grain in Fact Table Design

6.1 What Is Grain?

Grain defines exactly what one row in a fact table represents. Establishing the grain is one of the most important decisions in dimensional modeling because it determines which records can be stored together and which measures can be calculated correctly.

Examples of grain include:

  • One row per sales order line.
  • One row per individual payment transaction.
  • One row per product per store per day.
  • One row per employee per month.
  • One row per inventory item per warehouse per day.

6.2 Example of Transaction-Level Grain

Suppose an order contains three different products. A sales fact table with one row per order line could contain:

OrderID LineNumber ProductID Quantity SalesAmount
O1001 1 P101 2 1000
O1001 2 P102 1 800
O1001 3 P103 4 600

Each row represents one product line within an order, not the entire order. The order identifier therefore repeats because one order can contain multiple lines.

6.3 Why Grain Matters

  • Prevents accidental duplication of measurements.
  • Clarifies which columns identify a fact record.
  • Helps determine the appropriate foreign keys.
  • Improves the accuracy of sales and quantity calculations.
  • Supports meaningful aggregation across different dimensions.
  • Prevents mixing data at incompatible levels of detail.

6.4 Best Practices for Defining Grain

  1. Identify the business process being measured.
  2. Write a clear statement describing one row.
  3. Determine the level of detail available in the source.
  4. Identify the dimensions relevant to that level of detail.
  5. Determine which columns or combinations uniquely identify records.
  6. Validate that numeric measures are recorded at the selected grain.
  7. Document the grain for future developers and report users.

7. Types of Fact Tables

7.1 Transaction Fact Table

A transaction fact table records individual business events as they occur. Each row typically represents a transaction or a transaction line.

Examples: Sales transactions, order lines, payments, invoices, and website purchases.

Advantages:

  • Provides detailed business information.
  • Supports flexible analysis across dimensions.
  • Allows users to aggregate data over different periods.
  • Supports drill-down analysis to individual transactions.

7.2 Periodic Snapshot Fact Table

A periodic snapshot fact table records measurements at regular intervals, such as daily, weekly, or monthly.

For example, a monthly inventory snapshot may contain the quantity available for each product in each warehouse at the end of every month.

Month ProductID WarehouseID ClosingStock
January P101 W01 500
February P101 W01 420
March P101 W01 390

This table supports inventory trend analysis. ClosingStock is usually semi-additive across time: adding closing balances across several months does not normally represent a meaningful stock balance.

7.3 Accumulating Snapshot Fact Table

An accumulating snapshot fact table tracks a process that progresses through defined milestones. The same row is updated as the process advances.

For example, an order-processing table may track order creation, payment, dispatch, and delivery dates.

OrderID OrderDate PaymentDate DispatchDate DeliveryDate
O1001 2026-01-01 2026-01-01 2026-01-02 2026-01-05
O1002 2026-01-03 2026-01-04 2026-01-05 2026-01-08

This design helps measure the time taken between milestones, such as order creation and delivery.

7.4 Factless Fact Table

A factless fact table records the occurrence of an event or an association without requiring a numeric measure.

Examples include:

  • Student enrollment in a course.
  • Employee attendance at a training session.
  • A customer being eligible for a promotion.
  • A student attending a class.

Even without a numeric amount column, the rows can be counted to answer business questions, such as how many students enrolled in each course.

8. Types of Measures in Fact Tables

Measures are values used to evaluate business performance. Their aggregation behavior depends on the meaning of the data.

8.1 Additive Measures

Additive measures can be summed across all relevant dimensions.

Examples include:

  • Sales revenue.
  • Units sold.
  • Transaction counts when defined at the correct grain.
  • Shipping costs.

For example, daily sales can generally be summed to calculate monthly sales, provided the records do not duplicate the same sales events.

8.2 Semi-Additive Measures

Semi-additive measures can be summed across some dimensions but not all dimensions, particularly time.

Examples include:

  • Bank account balances.
  • Inventory on hand.
  • Outstanding loan balances.
  • Headcount measured at a specific point in time.

For example, the closing inventory of several different warehouses can often be summed for the same date. However, adding January's closing stock to February's closing stock does not usually represent a meaningful inventory balance.

8.3 Non-Additive Measures

Non-additive measures should not be summed directly across the relevant dimensions.

Examples include:

  • Profit margin percentages.
  • Conversion rates.
  • Average selling prices.
  • Ratios and percentages.

These values are usually recalculated from their underlying components when aggregated.

For example, overall profit margin should normally be calculated from total profit divided by total revenue rather than by summing individual margin percentages.

9. Designing Dimension Tables

9.1 Select the Business Entity

Start by identifying the entity the dimension represents. Common entities include customers, products, employees, locations, and dates.

Each dimension should have a clear business purpose and a defined level of detail.

9.2 Choose a Unique Key

A dimension table should generally contain a key that uniquely identifies each row. In a warehouse-style model, this is often a surrogate key generated independently of the source system's business identifier.

For example:

ProductKey ProductID ProductName Category
201 P101 Laptop Electronics
202 P102 Mouse Accessories
203 P103 Keyboard Accessories

ProductKey is the dimension key, while ProductID is the source business identifier.

9.3 Include Useful Descriptive Attributes

Dimension attributes should help users understand and categorize facts.

A Product dimension may contain:

  • Product name.
  • Product category.
  • Subcategory.
  • Brand.
  • Product size.
  • Product color.
  • Product status.

A Customer dimension may contain customer name, segment, city, state, country, and acquisition channel.

9.4 Avoid Unnecessary Columns

Include attributes that support reporting requirements, filtering, grouping, or meaningful business analysis. Avoid importing unnecessary fields simply because they exist in the source.

Reducing unnecessary columns can simplify the model, reduce storage requirements, and make the field list easier for report authors to use.

9.5 Handle Duplicate Business Records

Dimension sources may contain duplicate records for the same business entity. Before creating the dimension, determine whether duplicates are accidental or represent legitimate historical versions.

Possible approaches include:

  • Removing duplicate source records when they are genuinely redundant.
  • Standardizing business identifiers.
  • Combining records from multiple source systems using appropriate matching rules.
  • Maintaining separate historical versions when the model needs to track changes over time.

10. Understanding Surrogate Keys and Natural Keys

10.1 Natural Key

A natural key is an identifier that originates from the business domain or source system.

Examples include CustomerID, ProductCode, EmployeeNumber, and InvoiceNumber.

10.2 Surrogate Key

A surrogate key is an identifier created specifically for data modeling or data warehousing. It does not need to carry business meaning.

Examples include CustomerKey values such as 101, 102, and 103.

Feature Natural Key Surrogate Key
Origin Business system. Generated for modeling purposes.
Meaning Often has business meaning. Usually has no business meaning.
Stability May change or differ across source systems. Can remain stable within the modeled dataset.
Example CUST-001 101
Typical Use Source identification and matching. Dimension-to-fact relationships.

Surrogate keys are particularly useful when integrating multiple source systems or maintaining historical versions of dimension records. In simpler Power BI models, a stable, unique business key may be sufficient if it meets the modeling requirements.

11. Designing a Star Schema in Power BI

11.1 What Is a Star Schema?

A star schema is a dimensional model in which a central fact table connects to several dimension tables. The dimensions provide context for analyzing the facts.

It is a common and recommended modeling pattern for Power BI because it provides clear relationships and predictable filtering behavior.

11.2 Example Star Schema

                    Date Dimension
                          |
                          | 1
                          |
                          *
Customer Dimension 1 --- * Sales Fact * --- 1 Product Dimension
                          |
                          *
                          |
                    Store Dimension

In this model, the Sales fact table is connected to Date, Customer, Product, and Store dimensions through one-to-many relationships. Each dimension can filter the fact table.

11.3 Benefits of a Star Schema

  • Provides a clear and understandable model structure.
  • Supports intuitive filtering and slicing.
  • Reduces unnecessary repetition of descriptive attributes in fact tables.
  • Helps DAX measures behave predictably.
  • Supports reusable dimensions across multiple reports.
  • Can improve model usability and performance when designed appropriately.
  • Makes it easier to organize hierarchies and reporting categories.

11.4 Star Schema vs. Flat Table

Feature Star Schema Flat Table
Structure Fact and dimension tables. Most information stored in one table.
Data Repetition Descriptive attributes are generally stored in dimensions. Descriptive attributes may repeat across transactions.
Model Relationships Uses explicit relationships. May require fewer relationships.
Maintenance Supports reusable dimensions and organized modeling. Can become difficult to maintain as complexity grows.
Best Use Analytical models with multiple dimensions and facts. Simple datasets or limited reporting scenarios.

A flat table is not always wrong. It can be suitable for small or simple datasets. A star schema becomes particularly valuable as reporting needs and data complexity increase.

12. Creating Relationships Between Fact and Dimension Tables

12.1 Example Relationship Structure

Suppose the model contains:

  • Sales fact table.
  • Customer dimension.
  • Product dimension.
  • Date dimension.

The relationships are:

Customer[CustomerKey]  1 ---- * Sales[CustomerKey]
Product[ProductKey]    1 ---- * Sales[ProductKey]
Date[DateKey]          1 ---- * Sales[DateKey]

12.2 Steps to Create Relationships

  1. Load the fact and dimension tables into Power BI Desktop.
  2. Open Model view.
  3. Locate the relevant fact and dimension tables.
  4. Drag the dimension key onto the matching foreign key in the fact table.
  5. Set the cardinality to One-to-many (1:*) when appropriate.
  6. Set cross-filter direction to Single for the typical dimension-to-fact relationship.
  7. Ensure the relationship is active unless there is a specific reason to keep it inactive.
  8. Repeat for the remaining dimensions.
  9. Check that the one-side keys are unique.
  10. Test filtering and measures in Report view.

12.3 Why Single-Direction Filtering Is Common

In a typical star schema, dimension tables filter the fact table. For example, selecting a product category filters Products and then filters Sales through the active relationship.

Single-direction filtering helps keep the model's filter paths clear and reduces the risk of ambiguous relationships.

13. Creating a Date Dimension

13.1 Importance of a Date Dimension

A Date dimension allows users to analyze business data by year, quarter, month, week, and day. It also supports time intelligence calculations when the model is configured correctly.

A Date dimension may contain:

  • Date.
  • DateKey.
  • Year.
  • Quarter.
  • Month Number.
  • Month Name.
  • Week Number.
  • Day Name.
  • Fiscal Year.

13.2 Example Date Dimension

DateKey Date Year MonthNumber MonthName Quarter
20260101 2026-01-01 2026 1 January Q1
20260102 2026-01-02 2026 1 January Q1
20260201 2026-02-01 2026 2 February Q1

13.3 Creating a Date Table Using DAX

The following DAX expression creates a basic date table:

Date =
ADDCOLUMNS(
    CALENDAR(
        DATE(2025, 1, 1),
        DATE(2027, 12, 31)
    ),
    "Year", YEAR([Date]),
    "MonthNumber", MONTH([Date]),
    "MonthName", FORMAT([Date], "MMMM"),
    "Quarter", "Q" & FORMAT([Date], "Q")
)

After creating the table:

  1. Verify that the Date column contains unique, contiguous dates for the required period.
  2. Mark the table as a date table using the Date column when appropriate.
  3. Sort MonthName by MonthNumber to display months chronologically.
  4. Create the relationship between Date[Date] and the relevant date column in the fact table.
  5. Extend the date range to cover the reporting requirements.

14. Designing Fact Tables for Multiple Business Processes

Organizations often need to analyze more than one business process. For example, a retail business may track sales, returns, inventory, and budgets.

14.1 Sales Fact Table

Grain: One row per sales order line.

Typical columns:

  • DateKey.
  • CustomerKey.
  • ProductKey.
  • StoreKey.
  • QuantitySold.
  • SalesAmount.
  • DiscountAmount.
  • CostAmount.

14.2 Returns Fact Table

Grain: One row per returned product line.

Typical columns:

  • ReturnDateKey.
  • CustomerKey.
  • ProductKey.
  • StoreKey.
  • ReturnQuantity.
  • RefundAmount.

14.3 Inventory Fact Table

Grain: One row per product per warehouse per snapshot date.

Typical columns:

  • DateKey.
  • ProductKey.
  • WarehouseKey.
  • OpeningStock.
  • ClosingStock.
  • StockValue.

14.4 Shared Dimensions

Sales, Returns, and Inventory may share dimensions such as Product and Date. These shared dimensions allow users to compare different business processes using consistent categories and time periods.

For example, a Product dimension can filter both Sales and Returns. A Date dimension can be used for sales date analysis and return date analysis, provided the date relationships and role-playing requirements are modeled appropriately.

15. Understanding Slowly Changing Dimensions

15.1 What Is a Slowly Changing Dimension?

A slowly changing dimension (SCD) is a dimension whose attributes change over time. For example, a customer may move to a different city or a product may be assigned to a different category.

Historical reporting requirements determine how these changes should be stored.

15.2 Type 1: Overwrite the Previous Value

Type 1 replaces an old attribute value with the new value. It does not preserve the old value in the dimension.

Example: A customer spelling correction updates the customer name directly.

Advantages: Simple implementation and no additional historical dimension records.

Limitation: Reports generally show the current corrected value rather than the previous value.

15.3 Type 2: Preserve Historical Versions

Type 2 creates a new dimension record when a tracked attribute changes. Each version has its own surrogate key and effective dates or a current-record indicator.

CustomerKey CustomerID City StartDate EndDate IsCurrent
101 C001 Mumbai 2024-01-01 2025-06-30 No
205 C001 Pune 2025-07-01 9999-12-31 Yes

The same business customer has two dimension records because the customer's city changed. Historical fact records retain the dimension key associated with the appropriate version.

Advantages: Supports historical analysis using the attributes applicable at the time of the event.

Limitation: Requires more complex data preparation and key management.

16. Building Measures from Fact Tables

16.1 Total Sales

Total Sales =
SUM(Sales[SalesAmount])

This measure calculates total sales in the current filter context.

16.2 Total Quantity Sold

Total Quantity Sold =
SUM(Sales[Quantity])

This measure calculates the total number of units sold across the selected transactions.

16.3 Total Cost

Total Cost =
SUM(Sales[CostAmount])

16.4 Total Profit

Total Profit =
[Total Sales] - [Total Cost]

16.5 Profit Margin

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

Format this measure as a percentage. The DIVIDE function safely handles a zero denominator by returning the specified alternate result.

16.6 Why Measures Are Important

Measures calculate results dynamically based on the filters applied by dimensions. For example, Total Sales can return different results when users select a customer, product category, region, or year.

Whenever possible, use measures for analytical calculations instead of storing every aggregate as a separate static column.

17. Common Mistakes in Fact and Dimension Table Design

Mistake Impact Recommended Solution
Undefined fact grain Duplicate records or incorrect totals. Define exactly what one row represents.
Duplicate dimension keys One-to-many relationships may fail or become invalid. Validate uniqueness and clean dimension data.
Mixing different grains Measures may be aggregated incorrectly. Use separate fact tables for different business processes or levels of detail.
Storing descriptive attributes repeatedly in facts Unnecessary storage and difficult maintenance. Move reusable descriptions into dimension tables where appropriate.
Using fact tables as lookup tables Unclear filter behavior and duplicate categories. Create suitable dimensions with unique keys.
Incorrect aggregation of balances Inventory or account totals become misleading. Use measures that respect semi-additive behavior.
Ignoring historical changes Past reports may display current attributes incorrectly. Choose an appropriate slowly changing dimension strategy.
Creating unnecessary bidirectional relationships Ambiguous filter paths and unexpected report results. Prefer simple dimension-to-fact filtering.
Using text for numeric measures Aggregation and calculations may fail. Apply appropriate data types and validate source values.
Loading unnecessary columns Larger models and a confusing field list. Keep only the columns needed for analysis.

18. Practical Project: Retail Sales Data Model

18.1 Project Objective

Design a Power BI star schema for a retail company that wants to analyze sales performance by customer, product, date, and store.

18.2 Required Tables

  • FactSales.
  • DimCustomer.
  • DimProduct.
  • DimDate.
  • DimStore.

18.3 FactSales Structure

Column Description
SalesKey Unique sales-row identifier, if required.
DateKey Reference to DimDate.
CustomerKey Reference to DimCustomer.
ProductKey Reference to DimProduct.
StoreKey Reference to DimStore.
Quantity Units sold.
UnitPrice Price per unit at transaction time.
DiscountAmount Discount associated with the sales line.
SalesAmount Net or gross sales value according to the defined business rule.
CostAmount Cost associated with the transaction.

18.4 DimProduct Structure

Column Description
ProductKey Unique dimension key.
ProductID Source product identifier.
ProductName Product description.
Category Product category.
Subcategory More detailed classification.
Brand Product brand.

18.5 DimCustomer Structure

Column Description
CustomerKey Unique dimension key.
CustomerID Business identifier.
CustomerName Customer name.
City Customer city.
State Customer state.
CustomerSegment Customer classification.

18.6 Implementation Steps

  1. Import the sales and lookup datasets.
  2. Inspect source data types and data quality.
  3. Define the grain of FactSales as one row per sales order line.
  4. Create or validate unique keys in each dimension.
  5. Remove unnecessary columns and clean descriptive attributes.
  6. Create the relationships between FactSales and each dimension.
  7. Set the correct cardinality and cross-filter direction.
  8. Create measures for total sales, quantity, cost, profit, and profit margin.
  9. Build visuals for sales by month, product category, customer segment, and store.
  10. Validate report totals against the source data.

18.7 Expected Report Outcomes

  • Sales trends by year and month.
  • Best-selling products and categories.
  • Revenue by customer segment.
  • Store-level performance comparisons.
  • Profit and profit margin analysis.
  • Quantity sold across different periods.

19. Performance and Maintenance Best Practices

  • Use a clear star schema for analytical models whenever appropriate.
  • Keep fact tables at a consistent and documented grain.
  • Remove unnecessary columns before loading data into the model.
  • Use appropriate data types for keys, dates, quantities, and amounts.
  • Prefer unique dimension keys and one-to-many relationships.
  • Use shared conformed dimensions when multiple fact tables need consistent analysis.
  • Hide technical key columns from report users when they do not need them.
  • Use measures for calculations that must respond dynamically to filters.
  • Validate semi-additive and non-additive calculations carefully.
  • Review data quality, relationships, and refresh behavior after source changes.
  • Consider incremental refresh for large fact tables when supported and appropriate.
  • Document table grain, business rules, key definitions, and measure logic.

20. Practice Exercises

Exercise 1: Identify Fact and Dimension Tables

Consider a retail dataset containing Orders, Customers, Products, Stores, and Dates. Identify which table should function as the fact table and which tables should function as dimensions. Explain your reasoning.

Exercise 2: Define Fact Table Grain

Design a Sales fact table. Decide whether one row represents an entire order or an individual order line. Explain how the decision affects quantity, sales, and product analysis.

Exercise 3: Build a Star Schema

Create FactSales, DimCustomer, DimProduct, and DimDate tables. Establish one-to-many relationships and test how the dimensions filter sales.

Exercise 4: Create a Date Dimension

Build a date table with Year, Quarter, Month Number, Month Name, and Date. Sort Month Name by Month Number and connect the date table to the fact table.

Exercise 5: Analyze Measure Types

Classify sales revenue, inventory balance, and profit margin as additive, semi-additive, or non-additive measures. Explain how each should be aggregated.

Exercise 6: Handle Changing Attributes

Suppose a customer moves from Mumbai to Pune. Explain the difference between overwriting the city and preserving historical versions using a Type 2 slowly changing dimension.

21. Interview Questions and Answers

Q1. What is a fact table in Power BI?

Answer: A fact table records business events or observations and usually contains foreign keys and measurable values such as quantity, revenue, cost, or transaction count.

Q2. What is a dimension table?

Answer: A dimension table contains descriptive attributes used to filter, group, classify, and analyze facts. Customers, Products, and Dates are common examples.

Q3. What is the difference between fact and dimension tables?

Answer: Fact tables store measurements and events, while dimension tables store descriptive information that provides context for analyzing those measurements.

Q4. What is the grain of a fact table?

Answer: Grain defines exactly what one row represents, such as one sales order line or one inventory record per product per day.

Q5. What is a star schema?

Answer: A star schema is a dimensional model in which a central fact table connects to dimension tables, usually through one-to-many relationships.

Q6. What is a surrogate key?

Answer: A surrogate key is an identifier created for data modeling rather than taken directly from the business system. It uniquely identifies dimension records.

Q7. What is a natural key?

Answer: A natural key is an identifier originating from the business domain, such as CustomerID or ProductCode.

Q8. What are the main types of fact tables?

Answer: The main types are transaction fact tables, periodic snapshot fact tables, accumulating snapshot fact tables, and factless fact tables.

Q9. What is an additive measure?

Answer: An additive measure can be summed across all relevant dimensions, such as transaction-level sales revenue or units sold.

Q10. What is a semi-additive measure?

Answer: A semi-additive measure can be summed across some dimensions but not all. Inventory balances and account balances are common examples.

Q11. What is a non-additive measure?

Answer: A non-additive measure, such as a percentage or ratio, should generally be recalculated from its underlying components rather than summed.

Q12. Why should dimension keys be unique?

Answer: Unique dimension keys allow Power BI to establish valid one-to-many relationships and ensure that dimension records can be identified reliably.

Q13. What is a slowly changing dimension?

Answer: It is a dimension design approach for handling changes in descriptive attributes over time. Type 1 overwrites values, while Type 2 preserves historical versions.

Q14. Can multiple fact tables share the same dimension?

Answer: Yes. Shared dimensions, also known as conformed dimensions when consistently defined, allow different fact tables to be analyzed using common categories such as Product or Date.

Q15. Why is a star schema useful in Power BI?

Answer: It creates a clear model structure, supports predictable filtering, improves usability, and makes measures and relationships easier to maintain.

22. Quick Revision Checklist

  • Understand the purpose of fact tables and dimension tables.
  • Define the grain before designing a fact table.
  • Identify the appropriate foreign keys and dimension keys.
  • Use unique keys for dimension records.
  • Recognize transaction, periodic snapshot, accumulating snapshot, and factless fact tables.
  • Distinguish additive, semi-additive, and non-additive measures.
  • Organize the model using a star schema where appropriate.
  • Create one-to-many relationships from dimensions to facts.
  • Use a date dimension for consistent time analysis.
  • Understand natural keys, surrogate keys, and historical dimension changes.
  • Validate measures and totals against trusted source data.
  • Document table grain and business rules for maintainability.

23. Conclusion

Designing fact tables and dimension tables is a fundamental skill for building reliable Power BI data models. Fact tables capture business events and measurements, while dimension tables provide descriptive context for analyzing those events.

A successful model begins with a clearly defined grain, appropriate keys, useful descriptive attributes, and well-designed relationships. A star schema typically provides a practical structure for connecting dimensions to facts, while careful treatment of additive, semi-additive, and non-additive measures helps ensure accurate reporting.

By applying these principles, Power BI developers can create models that are easier to understand, maintain, and extend as business requirements grow.


Explore Microsoft Power BI Training: View the Microsoft Power BI Course

Register for a Demo: Register for a Course Demo

Visit JustAcademy: www.justacademy.co

whatsapp