Saturday 29 August 2015

Role Playing Dimension in Tabular Model(SSAS)

Role Playing dimension is a single dimension which has multiple references with the fact. Each of these references logically means a different role. Date dimension is the commonly used role playing dimension. The fact dimensions used to have different date columns and the date dimensions used to have reference to these columns.

In Tabular model there is no direct way to define different role to the a dimension. There are some work around to available to get role based dimension feature. 

Let's take the AdventureWorks example:

In this example we will take FactInternetSales dimension and DimDate dimesion. Following are the date keys those are present in the fact:

  1. OrderDateKey
  2. DueDateKey
  3. ShipDateKey
Create the first relationship between FactInternetSales and DimDate on the basis of Order Date.


This is the active relation between FactInternetSales and DimDate.

Now create the relation between FactInternetSales and DimDate on the basis of Ship Date.


You can find the active checkbox is unchecked and there a dotted line between FactInternetSales and DimDate which represent the inactive relationship.


This is how you can have multiple relationships between a fact and a dimension. Now we will use these relations while calculating measure.

Create a measure Internet Total Sales:=SUM([SalesAmount]).


Process the cube and analyse the data in an excel. After analyzing you will found the measure is calculated on the basis of active relationship which is Order Date.




Now let's create another measure by using the inactive relation Ship Date.

Internet Total Sales on Ship Date:=CALCULATE(SUM([SalesAmount]),USERELATIONSHIP(FactInternetSales[ShipDateKey],DimDate[DateKey]))




Process the cube and analyse the data in an excel. After analyzing you will found the measure is calculated on the basis of in-active relationship which is Ship Date.