PREP WITH PROOF
Menu
MICROSOFT FABRIC / PRACTICAL GUIDE

Fabric SCD Type 2: Find the Right Surrogate Key for a Fact

Resolve a Type 2 customer surrogate key by order date in Fabric. Test a change boundary, a late order, and a missing match in a worked DP-700 example.

THE QUICK ANSWER

In a Fabric Warehouse Type 2 dimension, resolve each transaction to the dimension version valid when the event happened. Match the source business key and the event date, then store the resolved surrogate key on the fact. Use an inclusive start and exclusive end in this example so an order on a change boundary matches exactly one version.

Start with the question the report must answer

A retailer wants to group sales by the customer region at the time of purchase. Its source sends one row per order line with customer details repeated. Build a transaction fact at order-line grain with its measures and dimension keys. Store versioned customer attributes once per relevant change in DimCustomer.

Type 1 overwrites the old region and is suitable when reports only need the latest value. Type 2 gives each tracked version its own surrogate key. The stable CustomerID still identifies the customer across versions. This distinction explains why the reporting requirement drives the loading choice.

Source: Microsoft Learn: Understand star schema and slowly changing dimensions ↗

Trace four order lines across the effective date

Customer C17 moved from North to West on October 15, 2026. In DimCustomer, key 101 covers October 1 up to October 15, excluding the end date. Key 102 starts October 15 and has a null end date while the version is open. StgOrderLine uses unique order-line IDs and business dates in the same calendar as the dimension.

An order loaded on October 20 can still belong to North if its order date was October 12. In this example, joining to the current row or using the arrival date would silently put that transaction in West.

Order lineCustomerOrder dateArrivedExpected lookup
5101C172026-10-122026-10-20101 (North)
5102C172026-10-152026-10-15102 (West)
5103C172026-10-192026-10-19102 (West)
5104C992026-10-192026-10-19No match

Source: Microsoft Learn: Model dimension tables in Fabric Warehouse ↗

Count matches before attaching a dimension key

Use this read-only validation query once the relevant customer history has been prepared. Its left join keeps order line 5104 visible. Review a match count of zero under your unknown-member or suspense policy. More than one match flags overlapping versions or duplicated dimension data. In either case, the query leaves the resolved key null.

The expected match counts by order line are 1, 1, 1, and 0. If you accidentally leave version 101 valid through October 16, line 5102 produces two matches. That is why choosing the smallest available key without counting matches would hide a data defect. Preserve the order line and resolve its exception under your loading policy.

SELECT
    s.OrderLineID,
    COUNT(d.CustomerKey) AS MatchCount,
    CASE WHEN COUNT(d.CustomerKey) = 1
         THEN MIN(d.CustomerKey) END AS ResolvedCustomerKey
FROM StgOrderLine AS s
LEFT JOIN DimCustomer AS d
    ON d.CustomerID = s.CustomerID
   AND s.OrderDate >= d.ValidFrom
   AND (s.OrderDate < d.ValidTo OR d.ValidTo IS NULL)
GROUP BY s.OrderLineID
ORDER BY s.OrderLineID;

Source: Microsoft Learn: Load tables in a Fabric dimensional model ↗

Practice question: Which choice keeps history correct?

Assume finance requires the old report to stay grouped by the region when each order occurred. Which design handles both late orders and changes to descriptive attributes?

A. Keep a wide fact and overwrite every old region when the customer moves. B. Store a single customer row and join each fact to the current region by CustomerID. C. Separate the order-line fact and customer dimension, version the region, and resolve the fact key against the order date.

Choose C. A rewrites historical classification. B can look correct on a report that only shows current orders, but gives the wrong answer for the late October 12 order. C preserves North and West for the dates when each applied. In a source that only delivers the current customer state, first confirm where effective dates and earlier versions can be recovered.

Source: Microsoft Learn: Load tables in a Fabric dimensional model ↗

KEEP THESE THREE THINGS

Your next steps

  1. Define the order-line grain before splitting the wide feed.
  2. Use the event date to find the historical dimension version.
  3. Check for zero and multiple matches before assigning a key.

Sources & official resources

Linked resources checked on 2026-11-29. Technical behavior and provider guidance can change; check the documentation for the version you use.

About this guide and its recommendations

Published by Prep With Proof with AI-assisted drafting. Study routines and examples are editorial suggestions, not official exam instructions or claims of a learner's personal results. Cited provider facts are linked; ownership of recommended Prep With Proof products is disclosed. No competitor endorsement or guaranteed certification outcome is implied.

Suggest a correction →