Tags:

In Power BI and other data modeling environments, Dimension Tables and Fact Tables are two core components of a star schema or snowflake schema that structure the data for reporting and analysis.

start-schema-overview

1. Fact Table:

The Fact Table is the central table in a data model. It stores quantitative data (facts) that can be aggregated and analyzed. It typically contains numeric measures (such as sales, profit, quantity) and foreign keys that link to the dimension tables.

Example of a Fact Table:

Consider a sales database. A Sales Fact Table may look like this:

SalesIDProductIDDateIDStoreIDQuantitySoldSalesAmount
110120230115100
21022023012360
310320230218160
41012023023240

Here:

  • SalesID is a unique identifier for each sale transaction.
  • ProductID, DateID, and StoreID are foreign keys that link to dimension tables.
  • QuantitySold and SalesAmount are facts (measures).

2. Dimension Table:

The Dimension Tables contain descriptive attributes or categorical information. These tables help provide context to the facts and are typically used to filter, group, or aggregate the data. They are linked to the fact table using foreign keys.

Example of Dimension Tables:

  • Product Dimension Table:
ProductIDProductNameCategory
101Widget AElectronics
102Widget BApparel
103Widget CFurniture
  • Date Dimension Table:
DateIDDateMonthYear
2023012023-01-01Jan2023
2023022023-02-01Feb2023
  • Store Dimension Table:
StoreIDStoreNameLocation
1Store OneNew York
2Store TwoChicago
3Store ThreeLos Angeles

Relationships between Tables:

In this example:

  • The Sales Fact Table links to the Product Dimension Table using ProductID.
  • The Sales Fact Table links to the Date Dimension Table using DateID.
  • The Sales Fact Table links to the Store Dimension Table using StoreID.

This star schema enables users to analyze sales by product, date, and store. For example, you can quickly query the total sales for a specific product in a particular store, within a certain date range.

Summary:

  • Fact Table: Stores quantitative data (facts) like sales, profit, etc.
  • Dimension Table: Stores descriptive information (like product names, dates, store locations) to provide context for the facts.

In Power BI, these tables are typically connected using relationships that allow users to build visualizations, aggregations, and reports.