Slowly changing dimension

What it is

A slowly changing dimension is a set of descriptive records whose
attributes can change over time. In a reporting model, a dimension
can describe customers, places, products or organisations. A change
may need to update what a report says today, preserve what was true
when an event happened, or do both. A slowly changing dimension
gives these changes an explicit storage and reporting policy.

One common policy, called Type 1, overwrites an attribute in the
existing dimension row. A spelling correction is often suitable for
this treatment. Another policy, called Type 2, adds a dimension
version for each change that should be visible in history. The
versions share a business identifier that identifies the same
entity. Each version usually has its own surrogate key, so an event
can refer to the description in effect at the relevant time.
Effective dates or timestamps describe when each version applies.

The policies can differ between attributes of one dimension. A
location's misspelled name can be corrected wherever it appears. A
change in the region responsible for that location can require
history for financial or operational reports. Make each choice
explicit, because it affects which facts will appear under an old or
new value when a report runs.

Why it matters

Consider a store that belongs to one sales region in January and
another in February. A report about current management might group
both months under today's region. A report that evaluates regional
targets for January needs the historical region that owned the store
when the sales occurred. The same fact records can support both
views if the model preserves the effective assignment and provides a
way to find the current one.

The policy also matters when records arrive late. A sales event from
January might be delivered after the store changes region. Joining
it to the current version would assign the sale to February's
organisation. A lookup based on the event date can choose the
historical version. This requires matching the model's dates to a
genuine business rule, such as transaction date or fulfillment date,
and using that meaning consistently across loading and reporting.

History takes more storage and makes each update a larger decision.
A Type 2 load often closes one interval and opens another. Consumers
have to know which version of a record they are reading. Record
history when it answers a real question, such as who owned a
location at an earlier time. Choose a simpler overwrite for a
correction that should consistently appear in all reports. The
decision is easier to revisit when its reporting purpose is stated
beside the model.

What it looks like in practice

Imagine a warehouse that collects daily usage facts for electricity
meter locations. Each location has a stable business code and its
regional assignment can change on the first day of a month. The
dimension stores a row with the old region and one with the new
region. Use a clear interval convention, such as a start that is
included and an end that is excluded. This gives a reading on the
transition date exactly one eligible interval.

When a fact arrives, locate its dimension version from the location
code and the reading date. Use the version's surrogate key in the
fact table, or use an equivalent query rule that always selects the
historical record. Also decide how to represent facts that arrive
before a dimension record is available. A warehouse can temporarily
place them under a clearly designated unknown member and reconcile
them after the correct dimension arrives. That behaviour needs to be
visible in the pipeline's results and checks.

Engineer's Power BI projects case study describes dashboards for
real-time and historical electrical and geographical data. The
example here illustrates a modelling decision relevant to that kind
of comparison. If a past reading and its location's current
assignment appear on the same screen, the report labels and joins
should make clear whether each figure follows the old region or the
current organisation.

Where it goes wrong

Overlapping effective dates can assign one fact to more than one
dimension version. Measuring totals before and after the join is a
simple way to detect a duplicate assignment. Also test a missing
period and the exact boundary value. The former should follow an
agreed unknown or rejected-record policy. The latter should match
exactly one row. Use the same timezone and date grain on both sides
of a lookup.

Updates can be more complicated when correction records arrive out
of order. Suppose a location actually changed region two weeks
before the effective date stored in the warehouse. A repair may need
to split an existing interval and reassign affected facts. Record
which reports have already been released and whether they are
expected to be restated. A correction mechanism should leave enough
evidence for a reviewer to explain why a historical figure changed.

The fact loader and dimension loader can also race. A fact may
arrive while the new effective version is still being written.
Coordinate the two loads so consumers see a consistent assignment,
or publish a bounded reconciliation step for unmatched facts.
Replaying the same input should preserve an existing version key
where the business change is identical. Stable keys make it easier
to repair a load without rewriting unrelated historical facts.

Finally, separate genuine change from changes in input formatting.
Variations in case, spacing or source codes can generate many
unnecessary history rows if a loader treats each as a new business
assignment. Compare canonical values or use an agreed identifier for
the relationship. Test one actual transition and one repeated
delivery of the same state. These exercises keep the history useful
for its intended readers and make a later data repair easier to
verify.

Further reading

  * Microsoft Power BI guidance on slowly changing dimensions.
Explains Type 1 and Type 2 history in a star schema.

  * Microsoft Fabric dimension-table modelling. Describes keys,
dimension layouts and history choices.

  * Microsoft Fabric dimensional table loads. Discusses how
dimension and fact loading interact.

hThis page on the web	URL:https://engineer.company/glossary/slowly-changing-dimension/	engineer.company	70
