Short answer: a slowly changing dimension is a dimension whose attributes change now and then: a customer moves, a product changes category. Type 1 overwrites the old value, so every report shows the new one. Type 2 closes the old row and adds a new one with dates, so last year's sales stay with last year's city. Choose per column, not per table.
The question is always the same: when a customer moves from Graz to Vienna, should last year's sales move with them? For a corrected typo, yes. For a sales region, usually not.
What does type 2 keep?
| CustomerKey | CustomerID | City | ValidFrom | ValidTo | IsCurrent |
|---|---|---|---|---|---|
| 88 | 1042 | Graz | 2023-05-14 | 2026-02-28 | 0 |
| 731 | 1042 | Vienna | 2026-03-01 | 9999-12-31 | 1 |
Two keys do two jobs. CustomerID is the business key from the source and stays the same. CustomerKey is the surrogate key: a new one per version, and the fact table stores it, so each sale points at the version that was true when it happened.
How do you load type 2?
Two steps: close the rows whose tracked columns changed, then insert a new version for every changed or new customer.
UPDATE d
SET ValidTo = DATEADD(day, -1, CAST(GETDATE() AS date)), IsCurrent = 0
FROM dim.Customer AS d
JOIN stage.Customer AS s ON s.CustomerID = d.CustomerID
WHERE d.IsCurrent = 1 AND s.City <> d.City;
INSERT INTO dim.Customer (CustomerID, Name, City, ValidFrom, ValidTo, IsCurrent)
SELECT s.CustomerID, s.Name, s.City, CAST(GETDATE() AS date), '9999-12-31', 1
FROM stage.Customer AS s
LEFT JOIN dim.Customer AS d ON d.CustomerID = s.CustomerID AND d.IsCurrent = 1
WHERE d.CustomerID IS NULL;After the update, a changed customer has no current row, so the insert adds its new version along with brand-new customers. Type 1 columns, like a corrected name, are a plain UPDATE on all rows of the customer.
What goes wrong?
- Facts joined on the business key. Join facts to the dimension by
CustomerKeywhen they load, or every sale shows the current city and type 2 did nothing. - Every column tracked. A type 2 change on a phone number makes a new row for nothing. Track only the columns reports group by.
- Nulls in the comparison.
s.City <> d.Cityis not true when one side is null. Compare withISNULLorIS DISTINCT FROM.
Where can you check this?
- Kimball Group: Type 2, add new row
- Microsoft Learn: Dimensional modeling in Fabric Data Warehouse: dimension tables
Where do you start?
The open course Upserts into Azure SQL builds the staging table and the merge by key that type 1 needs; type 2 adds the two steps above. In Fabric, the gold layer of bronze, silver and gold is where these dimensions live.