Wednesday, March 28, 2012

Grouping on part of a composite key in a dimension on one axis

Hi,

I've already posted the following: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=990233&SiteID=1&mode=1 but I think the way I presented the problem might be confusing, so I will rephrase the problem here:

We want to follow certain measures according to a parent-child dimension (related to the organisational chart of our company). Building a "conventional" Parent-Child using Analysis Services is fairly straight-forward: define the key and the parent.

But the conventional way does not answer one of our needs which is the following:

As the chart evolves, we want to keep the measure were they were in the chart, during a specific moment in time. E.g.:

Say Member A is under B during period X and A is under C during period Y (due to a "reorg"). If we follow the members count evolution of B and C we want to see A counted under B during period X and under C during period Y.

With a "conventional" parent-child dimention, I don't think we can achieve that, as we would only have the last hierarchy with A under C and it would seem as if A had always been under C.

So the idea was to have a table build like this:

Child Parent Period
=====================
A B X
B B X
C C X
A C Y
B B Y
C C Y

Here, we say B and C are both "root" of the tree during period X and Y.

Based on this table, how would I build a cube which will give me the evolution of the members count per member?

I've already tried the following:

1- Parent-Child dimension (let's call it "Hierarchy") where the key attribute is a composite key of Child+Period and the parent key is Parent+Period
2- Regular (or time) dimension based on Period (let's call it "Period")
3- A single Row count measure

This doesn't work perfectly because of the composite key. If I do an MDX query like this:

SELECT {(Period, Measures)} on Columns, {Hierarchy} on Rows FROM Cube, i'll get something like this:

All X Y
Hie... Count Count Count
B (BX) 2 2 null
B (BY) 1 null 1
C (CX) 1 1 null
C (CY) 2 null 2
All 6 3 3

Note: B (BX) means B (the name column) is displayed but the composite key is BX. the 2 under column X comes from A(1) + B(1), i.e. the count includes the parent.

So although I get the right numbers, I can't follow B or C on a single line (because of the composite key.

I've also tried using a Parent-Child dimension with only Child as the Key Column for the key and Parent as the key column for the parent, but then, I don't get the correct numbers.

Is there any way to structure a database/cube which will allow me to follow the information I want, the way I want it and/or a way to write a DMX query on the cubes I've tried which will give me the result I want?

Here is what I would like to see:

All X Y
Hie... Count Count Count
B 3 2 1
C 3 1 2
All 6 3 3

So? Anyone wants to give it a try? Still haven't had any luck making this work. I also haven't seen anything similar being done elsewhere.

I'd be gratefull for any help.

Thanks

No comments:

Post a Comment