Hello everybody,
I'm trying to optimize my MDX script and I'm currently stuck in the part which filters dimension members by properties. My data model contains:
1. DimHouseModel with attributes Name, DefaultKitchenType, DefaultNumberOfBedrooms
2. DimHouseConfiguration with attributes Name, KitchenType, NumberOfBedrooms
3. FactTable with regular relationships to DimHouseModel and DimHouseConfiguration + corresponding facts (for example, cost).
In DimHouseConfiguration there is a special member DefaultConfiguration which doesn't have any facts, instead it triggers the logic 'use the configuration defined as default in DimHouseModel'.
Corresponding MDX-Script statement looks like
SCOPE
(
[Measures].[Cost]
,[DimHouseConfiguration].[DimHouseConfiguration].[DefaultConfiguration]
);
THIS =
Sum(
Filter(
[DimHouseConfiguration].[DimHouseConfiguration].[DimHouseConfiguration].Members
,
(
[DimHouseModel].[DimHouseModel].Properties("DefaultKitchenType") = [DimHouseConfiguration].[DimHouseConfiguration].Properties("KitchenType")
AND
[DimHouseModel].[DimHouseModel].Properties("DefaultNumberOfBedrooms") = [DimHouseConfiguration].[DimHouseConfiguration].Properties("NumberOfBedrooms")
)
)
,[Measures].[Cost]
)
;
END SCOPE;
(May contain typos, as I'm simplifying my real data model, but you hopefully get the idea).
This works ok and returns correct results. Unfortunately, the performance degrades quite quickly as long as I add a couple of other (relevant) dimensions, especially with multiselect. The problem is only experienced when DefaultConfiguration is selected.
If I select a normal DimHouseConfiguration (not the artifical DefaultConfiguration), the queries return very quickly.
I've tried to formulate the scope logic with LinkMember(), but can't figure it out. In SQL Profiler I also see multiple QuerySubcube statements in the slow case (probably SSAS jumps into cell-by-cell mode, when the query space becomes complex enough from my
other dimensions and multiselects I add to the query).
KitchenType and NumberOfBedrooms identify a unique DimHouseConfiguration if this matters.
If you know, what I could try instead of this Filter(.Properties("")) way of filtering, please let me know. Thank you