Monday, February 29, 2016

SSAS: Dimension Parent Child Hierarchy recursive

In the last post I showed you know to build a Parent-Child Hierarchy. This time we implement the same Parent-Child Hierarchy in a different way. Building a Parent Child Hierarchy looks complicated but is easy if all the rules are followed correctly. I will here list down few steps which will help us building it better.

As you see below we have a simple table which you can build using SSIS and map the corresponding Parent and Child values.
Primary Column With unique IDs.
Portfolio Id of the corresponding Parent.
Operator used while aggregrating values(Auto Sum) from Child to Parent node.
You can read more on RollUps here

Example: P0120 has Parent P0200 and P0200 has Parent as P0500

 You can create a New SSAS Project and create the DataSourceView.
 After importing the table in the DataSource View we need to set the primary key.
Here Portfolio is set as Primary key.
 After that a link is created between Portfolio and ParentPortfolio as shown below.

Right Click "Dimension" folder in the Project in Visual Studio and Click "New Dimension".
The Dimesnion wizard opens up as shown below.
Select Portfolio Column as Key Column and for display we show the ID+Name combination which is already  there in the Description Column.

Select Portfolio and ParentPortfolio columns. You can add more columns like Name later on.

Name it "Portfolio".

Process the Dimension. The output is shown below.

Now we need to get rid of the Unknown member and set Rollup operator. For the Portfolio Dimension set the following Properties:

For Parent Portfolio Attribute set the following Properties:

Step 8:
Process the Dimension:
The Unknown Level will disappear and all the Levels will have the Unary Rollup sign.

Step 9:
Rename "Portfolio" attribute to "Portfolio Flat" and "Parent Portfolio" to Portfolio.
The reason we do is because I want to name my hierarchy attribute as "Portfolio".
Its helps a lot and is very user friendly for the EndUser.

This is how it should look like:

No comments:

Post a Comment