Slowly Changing Dimension

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

SLOWLY

CHANGING DIMENSION
by
WHAT IS SCD?
SCDs, Slowly Changing Dimensions, is a concept introduced by Ralph Kimball for data warehousing.

SCD deals with the movement of a specific dataset from one


state to another.

For example, we have an HR System where an employee


named Milagros E. Braun, a Sales Manager with 8 Sales
Representatives in her team.

In the present day, Milagros E. Braun has been promoted to


Vice President of Sales and her team grows from 8 to 16.
01 SCD TYPE ZERO (SCD 0)

In the case of SCD type zero (SCD 0), also known as


fixed dimension, we ignore every change that
occurred in a dimension. For example, if an employee's
residential address in the HR system (main source) gets
changed then we will not change the landing
dimension in our data warehouse.

02 SCD TYPE ONE (SCD 1)

In the case of SCD type one (SCD 1), we overwrite the

TYPES OF SCDs historical data with the new one. For example, when a
business does not need to maintain the old address of
their employee they'll overwrite it with the current
address.

03 SCD TYPE TWO (SCD 2)

In the case of SCD type two (SCD 2), we keep both the
historical as well as the new data in the data
warehouse. For example, when a business needs to
maintain the old address of their employee along with
the current address by inserting a new row of data
whenever a change happens in the transactional
system.
SCD TYPE 2
SCD type two (SCD 2) is the most commonly used case in Power BI where we deal with both
historical as well as current or newly added data in the rows. But, the addition of new rows causes
duplications which means we cannot use e.g. CustomerKey as the primary key of a dimension.

That's why we need to create a new set of columns which will include:

1. A new column key including the rows with unique Customer information. This will work as the
new Primary Key, also known as Surrogate Key, with a guarantee that every row introduced in
this domain is unique.
2. Another column will contain both StartDate and EndDate to represent the timeframe during
which row of the data is in its current state.
3. Another column will represent the status of each row.
Explanation of SCD 2 in Power BI
01

In the above example, Milagros E. Baum is currently working as a Sales Manager but later gets promoted to Vice
President of Sales. Here, the EmployeeKey is the Surrogate Key of the dimension and EmployeeBusinessKey is
the Business Key (the Primary Key of the main source system before promotion).

02

In the second dimension, we can see that Milagros E. Baum started working as Vice President of Sales on
8/12/2013 and left her position as Sales Manager on 8/11/2013. A new row has been added with a new
EmployeeKey, Title, StartDate and Status. But, the EmployeeBusinessKey which was the PrimaryKey of the
source system now contains duplicate values. This column cannot be used as a PrimaryKey.
Explanation of SCD 2 in Power BI
At this point, you might be thinking that can we implement the SCD 2 directly inside the Power BI Desktop
without having a data warehouse.

We create a semantic layer while creating a


model in Power BI. Semantic layer means the
view of the data warehouse or source has been
optimized for reporting and analytical purposes.
In case of a business wants to maintain
historical and current data then we need to have
either data warehousing or a transactional
system to maintain the historical data, this is
also known as a temporal mechanism.

After loading the SCD 2 type data into Power BI, As per the Business requirements, the
report must not contain the data except
at first glance the data might seems right to us. It
for the Current Status. With the help of
could be either wrong or right based on the
Advanced Filtering in Power BI
business's requirements. Desktop, we'll set the Status value as
either is not blank or is not empty.
Suppose the business only wants to view the This will remove the row for Milagros E.
total sales when the status is Current. Baum from the report.

You might also like