Hi All,
I would be grateful for your advice about the best way to implement in multidimensional cube the following situation:
I have got a standard star-schema (please see attached picture)
Fact_Actions - fact table
Dim_Agreements, Dim_Users and so on are dimensions
The problem is: dimensions DIM_Answers and DIM_Questions are linked to fact-table 16 times and in different reports only several combinations of Question_ID and Answer_ID are used, e.g.
SUM
(
CASE
WHEN
(FWORKS.ProjectQuestion_ID_1=7 AND FWORKS.ProjectAnswer_ID_1=21) OR
(FWORKS.ProjectQuestion_ID_2=7 AND FWORKS.ProjectAnswer_ID_2=21) OR
(FWORKS.ProjectQuestion_ID_3=7 AND FWORKS.ProjectAnswer_ID_3=21) OR
(FWORKS.ProjectQuestion_ID_4=7 AND FWORKS.ProjectAnswer_ID_4=21) OR
(FWORKS.ProjectQuestion_ID_5=7 AND FWORKS.ProjectAnswer_ID_5=21) OR
(FWORKS.ProjectQuestion_ID_6=7 AND FWORKS.ProjectAnswer_ID_6=21) OR
(FWORKS.ProjectQuestion_ID_7=7 AND FWORKS.ProjectAnswer_ID_7=21) OR
(FWORKS.ProjectQuestion_ID_8=7 AND FWORKS.ProjectAnswer_ID_8=21) OR
(FWORKS.ProjectQuestion_ID_9=7 AND FWORKS.ProjectAnswer_ID_9=21) OR
(FWORKS.ProjectQuestion_ID_10=7 AND FWORKS.ProjectAnswer_ID_10=21) OR
(FWORKS.ProjectQuestion_ID_11=7 AND FWORKS.ProjectAnswer_ID_11=21) OR
(FWORKS.ProjectQuestion_ID_12=7 AND FWORKS.ProjectAnswer_ID_12=21) OR
(FWORKS.ProjectQuestion_ID_13=7 AND FWORKS.ProjectAnswer_ID_13=21) OR
(FWORKS.ProjectQuestion_ID_14=7 AND FWORKS.ProjectAnswer_ID_14=21)OR
(FWORKS.ProjectQuestion_ID_15=7 AND FWORKS.ProjectAnswer_ID_15=21)OR
(FWORKS.ProjectQuestion_ID_16=7 AND FWORKS.ProjectAnswer_ID_16=21)
THEN 1
ELSE 0
END
)AS CountContacts
or
SUM
(
--PROJECTANSWER_ID=28
CASE
WHEN FWORKS.ProjectAnswer_ID_1 IN(28) OR FWORKS.ProjectAnswer_ID_2 IN (28) OR FWORKS.ProjectAnswer_ID_3 IN (28) OR FWORKS.ProjectAnswer_ID_4 IN (28) OR
FWORKS.ProjectAnswer_ID_5 IN(28) OR FWORKS.ProjectAnswer_ID_6 IN (28) OR FWORKS.ProjectAnswer_ID_7 IN (28) OR FWORKS.ProjectAnswer_ID_8 IN (28) OR
FWORKS.ProjectAnswer_ID_9 IN (28) OR FWORKS.ProjectAnswer_ID_10 IN (28) OR FWORKS.ProjectAnswer_ID_11 IN (28) OR FWORKS.ProjectAnswer_ID_12 IN(28) OR
FWORKS.ProjectAnswer_ID_13 IN (28) OR FWORKS.ProjectAnswer_ID_14 IN (28) OR FWORKS.ProjectAnswer_ID_15 IN (28) OR FWORKS.ProjectAnswer_ID_16 IN (28)
THEN 1
ELSE 0
END
)AS CountTaken
My question is what is the best way to handle this situation:
- create view like
SELECT F.AGREEMENT_ID,F.DATE_ID,F.USER_ID,
SUM
(
--PROJECTANSWER_ID=28
CASE
WHEN FWORKS.ProjectAnswer_ID_1 IN(28) OR FWORKS.ProjectAnswer_ID_2 IN (28) OR FWORKS.ProjectAnswer_ID_3 IN (28) OR FWORKS.ProjectAnswer_ID_4 IN (28) OR
FWORKS.ProjectAnswer_ID_5 IN(28) OR FWORKS.ProjectAnswer_ID_6 IN (28) OR FWORKS.ProjectAnswer_ID_7 IN (28) OR FWORKS.ProjectAnswer_ID_8 IN (28) OR
FWORKS.ProjectAnswer_ID_9 IN (28) OR FWORKS.ProjectAnswer_ID_10 IN (28) OR FWORKS.ProjectAnswer_ID_11 IN (28) OR FWORKS.ProjectAnswer_ID_12 IN(28) OR
FWORKS.ProjectAnswer_ID_13 IN (28) OR FWORKS.ProjectAnswer_ID_14 IN (28) OR FWORKS.ProjectAnswer_ID_15 IN (28) OR FWORKS.ProjectAnswer_ID_16 IN (28)
THEN 1
ELSE 0
END
)AS CountTaken
FROM FACT_TABLE AS F
GROUP BY F.AGREEMENT_ID,F.DATE_ID,F.USER_ID
and use this view in SSAS
- Create named calculations (I am not sure if it is possible)
- Do something else
Thank youforthe answers