Showing posts with label msdn. Show all posts
Showing posts with label msdn. Show all posts

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

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

sql

Friday, March 23, 2012

GROUPING at runtime

All...

I am using vb.net 2003. i am trying to set report groupings of a crystal report at runtime based on user defined options. MSDN says this:

Dim FieldDef As FieldDefinition
FieldDef =
Report.Database.Tables.Item(0).Fields.Item(comboBox1().Text)
Report.DataDefinition.Groups.Item(0).ConditionField = FieldDef

However, the .ConditionField is Read Only, you cannot assign anything to it. I have searched the object browser at each level of this object model, and cannot figure out how to assign a group to a report.

Heres the link to MSDN... the code for SORTING cr at runrime works perfectly, its just the GROUPING code im having trouble with...

http://msdn.microsoft.com/library/d...resentation.asp

Thanks.The following Example is specific to Crystal Reports 8.5 using RDC and VB6, but you may be able to tweak it a bit to work for you...

The following code can be used to Change the Group through VB Code:

1. In Crystal, create a Formula Field and add 1 column (a String column works best).
2. Insert a Group and choose your Formula for the GroupBy.
3. Now, you can comment out the Column you entered, or you can leave it there, your choice.
4. In VB, add this line of code, substituting {ttxFileName.ColumnName} for the column you want to sort by: Report.FormulaFields(1).Text = "{ttxFileName.ColumnName} ". The FormulaFields can only take a long for the index, so you need to know what number your Formula is so you don't replace the wrong one. The numbers start at 1 and are incremented based on the order they were created (they are listed in chronological order).