I new to OLAP, and still not sure how to create a relationship between 2 or more entities.
I am basing my cube on views. For simplicity sake let’s call them like this:
viewParent (ParentID PK)
viewChild (ChildID PK, ParentID FK)
these views have more fields, but they’re not important for this question.
in my data source, i defined a relationship between viewParent and viewChild using ParentID for the link.
As for measures, i was forced to create separate measures for Parent and Child.
in my MDX query however, the relationship does not seem to be enforced. If i select record count for parent, child, and add some filters for the parent, the child count is not reflecting it..
SELECT {
[Measures].[ParentCount],[Measures].[ChildCount]
} ON COLUMNS
FROM [Cube]
WHERE {
(
{[Time].[Month].&[2011-06-01T00:00:00]}
,{[SomeDimension].&[Foo]}
)
}
the selected ParentCount is correct, but ChildCount is not affected by any of the filters (because they are parent filters). However, since i defined a relationship, how can i take advantage of that to filter children by parent using a WHERE clause?
Facts:
viewParent, viewChild
Dimensions:
ParentDimension (contains attributes from parent view that i’d aggregate on)
ChildDimension (contains attributes from child view that i’d aggregate on)
This is just an idea i came up with, but maybe my design/relationship is off.
Figured it out.
Looking at the dimensions tab of the cube in vs2008 it became obvious.
my relationship between dimension and the measures was not set-up correctly. My dimension was keyed on uniqueID which corresponded to parentView uniqueID.
I changed the relationship (of SomeDimension) to key on a different ID field (shared by both parentView and childView) let’s call it ViewID.
and my MDX queries started working as expected. Meaning, WHERE clause affected both measure groups: parent and child.