Quantcast
Channel: SQLServerCentral » Data Warehousing » Analysis Services » Latest topics
Viewing all articles
Browse latest Browse all 1341

Group and drill down and roll up by the most recent SCD2 type member in reporting period in SSAS

$
0
0
Hello,I am new to SSAS and cube world so my problem might not be big of a challenge for you but it is for me.Here is my challenge :My simplified datamart relation star schema model looks like this (2 dimensions and one fact):DATE dimension - Date_Id, Date, Fiscal_Year, Fiscal_Quearter, Fiscal_Month, Calendar_Month, etc CLIENT dimension – Cient_SK, Client_Id, and two SCD2 type fields : Status,and Class and, of course, Start_Date, End_Date to keep track of SCD2 along with a Current_Flag . I can have several records for the same Client_Id over a given reporting period.FACT – Date_ID, Client_SK, Client_IdFact table is daily snapshot that loads one record per client only if a client was active on that day.Requirement: 1. Count number of currently active clients group by “Status” or “Class” with option to roll-up to the total count of clients2. Count total number of clients who were active in the specific reporting period (period can be fiscal year or fiscal quarter or a month) grouped by the most recent “Label” or most recent “Status” or most recent “Class” in that reporting period. I created a cube and created a measure “Distinct_Count” that does just that - distinct count on Client_Id. It works just fine for current date as well as for any given reporting period and I have nice rolling-up/down thru Fiscal_Year-Fiscal_Quarter- Month. But I am having problem grouping by any of 3 attributes with SCD2 type in the CLIENT dimension. I do not know how to get the latest active value (member) in the reporting period so I can group by that value.Here is my CLIENT dimension:Client_SK| Client_Id| Status| Class| Start_Date| End_Date| Current_Flag14| 78| fair| B| 03/01/2008| 27/09/2012| 073| 78| very good| C| 28/09/2012| 15/08/2013| 089| 78| Bad| B| 16/08/2013| 24/09/2013| 095| 78| Good| B| 25/09/2013| 03/10/2013| 097| 78| Good| A| 04/10/2013| 01/12/2013| 0102| 78| Average| A| 02/12/2013| 31/12/2099| 1If the selected reporting period is Fiscal_Quarter Q2 that covers period Aug-Sep-Oct (Client_SK: 89, 95, 97) and if my client was active in that period, when I group active client’s count by “Status” attribute I need to count this client in the group “Good” since that was the most recent value for this client in this period (Q2) for this attribute (Status).I have fixed reporting periods. Counting of active clients is required for:1.today (current)2. historic that can be one of the following three periods:a) end of fiscal_year, or b) end of fiscal_quarter, or c) end of month. Moving thru the periods (rolling up or down ) happens only thru the sequences Fiscal_Year--Fiscal_Quarter—Month and vice verse (I defined Calendar hierarchy in the DATE dimension of SSAS). So there is no requirements to go down to a specific date (other than today).For each selected period I have to be able to group my client counts by Status or by Class. That grouping is based on the most recent value of Status or Class in the selected period.In my Data Mart relational star model, beside daily snapshot of active clients fact table (mentioned earlier), I have generated three more fact tables with intention to help me to address this problem. There are:F_CLIENT_MONTH – Year_Month_Id, Client_SK, Client_Id, Status_Id, Class_IdF_CLIENT_FISCAL_QUARTER – Fiscal_Year_Quarter_Id, Client_SK, Client_Id, Status_Id, Class_IdF_CLIENT_FISCAL_YEAR - Fiscal_Year _Id, Client_SK, Client_Id, Status_Id, Class_IdEach fact table is a snapshot of active clients for that period (aggregate) and their respective values (Status_Id and Class_Id) at the end of that period. In other words Status_Id and Class_Id are calculated values for their respective periods for each client and loaded accordingly so there are ready to be used. Then I added two more dimensions with their respective attributes: DIM_STATUS – Status_Id, other attributesDIM_CLASS – Class_Id, other attributes.With this model in SSRS it would be easy to count active clients for current date (today) and then group by Status_Id or Class_Id based on Current_Flag. If I need to report on historic (predefined fiscal year, fiscal quarter or month ends of the periods) I would pass the parameters when moving from one period to another (basically moving from one aggregated fact table to another) and use pre-calculated values from the fact tables for that reporting period to display required counts when I need to group them by Status or Class. When it comes to SSAS and a cube I have no idea how to put this data model in action.The business users want to use cube as their data source so I am forced to use SSAS.Can I use the model I presented here to build a cube that will satisfy the requirements? If so how to do it? Minor adjustments to the model might not be the problem but my concern is, as I am running out of time, I might not be able to start from scratch with new data model. I do not know if this is important but just in case: user interface could be Excel application or any MDX enabled Microsoft or third party visualisation tool.Best Regards,Bob

Viewing all articles
Browse latest Browse all 1341

Trending Articles