Tuesday, September 23, 2014

How to work on Role Playing Dimension in QlikView

Role Playing Dimension nothing but a single physical dimension can be referenced multiple times in a fact table, with each reference linking to a logically distinct role for the dimension. For instance, a fact table can have several dates, each of which is represented by a foreign key to the date dimension.


For example, in our Adventure work database in FactInternetSales table have a DueDateKey, ShipDateKey and OrderDateKey. But our DimDate dimension has only one key that is Datekey.



Then we will see the how to perform single Datekey in Multiple action in FactTable


First I have use to RESIDENT load method to achieve



Step1: Select Edit Script icons (Ctrl+E)

Step2: Load the DimDate table and FactInternetSales table

Step3: Load the QVD file using RESIDENT method

Step4: Reload the script file

Step5: Then create a dashboard/report
 









Second Method I can modified the columns name in Dimension table like DateKey instead of DueDateKey, ShipDateKey and OrderDateKey.



For example:

DatePriod:
 
LOAD DateKey AS OrderDateKey,
DateKey AS DueDateKey,
DateKey AS ShipDateKey,
EnglishMonthName AS OrderMonthName,
EnglishMonthName AS DueMonthName,
EnglishMonthName AS ShipMonthName,
CalendarQuarter AS OrderCalendarQuarter,
CalendarQuarter AS DueCalendarQuarter,
CalendarQuarter AS ShipCalendarQuarter,
CalendarYear AS OrderCalendarYear,
CalendarYear AS DueCalendarYear,
CalendarYear AS ShipCalendarYear;
 

SQL SELECT *
FROM AdventureWorksDW2012.dbo.DimDate;