dbTalk Databases Forums  

Conditional MDX Staement

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Conditional MDX Staement in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rob Anderson
 
Posts: n/a

Default Conditional MDX Staement - 12-20-2004 , 10:57 AM






Hi Guys,

We're having some problems with an MDX statement defining a calculated
member. What we have is a cube with 2 different measures. We would like to
determine which measure to use based on one of the dimensions (lets call it
Products) .

The products dimension has 3 levels. Where the member is a descendant of 1
of the members in the first level then we want to use measure1, otherwise use
measure2.

The MDX looks like this:

iif(Ancestor([Product].CurrentMember, [Product].[level1]) is
[Product].[Level1].&[9],

[Measures].[Measure1],
[Measures].[Measure2]
)

This all looks fine in a pivot table but when I put the dimension on rows
and select 1 or more, but not all of the members in the dimension, the grand
total for the measure is never correct. Usually it's whatever the grandtotal
is for measure1 or measure2. Can anybody shed any light on this for me?

Reply With Quote
  #2  
Old   
Richard Tkachuk [MSFT]
 
Posts: n/a

Default Re: Conditional MDX Staement - 12-20-2004 , 01:03 PM






What do you want the calculation to show when you're at the all member in
the product dimension? The way the calculation is set up, it will be
Measure2 - this your intent?

--
_______________
Disclaimer : This posting is provided "AS IS" with no warranties, and
confers no rights.

"Rob Anderson" <Rob Anderson (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi Guys,

We're having some problems with an MDX statement defining a calculated
member. What we have is a cube with 2 different measures. We would like to
determine which measure to use based on one of the dimensions (lets call
it
Products) .

The products dimension has 3 levels. Where the member is a descendant of 1
of the members in the first level then we want to use measure1, otherwise
use
measure2.

The MDX looks like this:

iif(Ancestor([Product].CurrentMember, [Product].[level1]) is
[Product].[Level1].&[9],

[Measures].[Measure1],
[Measures].[Measure2]
)

This all looks fine in a pivot table but when I put the dimension on rows
and select 1 or more, but not all of the members in the dimension, the
grand
total for the measure is never correct. Usually it's whatever the
grandtotal
is for measure1 or measure2. Can anybody shed any light on this for me?



Reply With Quote
  #3  
Old   
Rob Anderson
 
Posts: n/a

Default Re: Conditional MDX Staement - 12-21-2004 , 01:59 AM



Hi Richard, thanks for your response. I want the All level to show the
aggregation of the 2 measures. This would mean allocating the amount for
measure1 to all descendants of prduct.level1 and allocating the amount for
measure2 to all other members and then aggregating. Any ideas?

"Richard Tkachuk [MSFT]" wrote:

Quote:
What do you want the calculation to show when you're at the all member in
the product dimension? The way the calculation is set up, it will be
Measure2 - this your intent?

--
_______________
Disclaimer : This posting is provided "AS IS" with no warranties, and
confers no rights.

"Rob Anderson" <Rob Anderson (AT) discussions (DOT) microsoft.com> wrote in message
news:5EB61F54-4F13-4F8B-AC67-3F0713DAC894 (AT) microsoft (DOT) com...
Hi Guys,

We're having some problems with an MDX statement defining a calculated
member. What we have is a cube with 2 different measures. We would like to
determine which measure to use based on one of the dimensions (lets call
it
Products) .

The products dimension has 3 levels. Where the member is a descendant of 1
of the members in the first level then we want to use measure1, otherwise
use
measure2.

The MDX looks like this:

iif(Ancestor([Product].CurrentMember, [Product].[level1]) is
[Product].[Level1].&[9],

[Measures].[Measure1],
[Measures].[Measure2]
)

This all looks fine in a pivot table but when I put the dimension on rows
and select 1 or more, but not all of the members in the dimension, the
grand
total for the measure is never correct. Usually it's whatever the
grandtotal
is for measure1 or measure2. Can anybody shed any light on this for me?




Reply With Quote
  #4  
Old   
Richard Tkachuk [MSFT]
 
Posts: n/a

Default Re: Conditional MDX Staement - 12-21-2004 , 02:52 PM



Something along the lines

iif(
Product.currentmember IS product.[All],
[measures].measures1 + [measures].measures2,
<your original expression>
)

--
_______________
Disclaimer : This posting is provided "AS IS" with no warranties, and
confers no rights.


"Rob Anderson" <RobAnderson (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi Richard, thanks for your response. I want the All level to show the
aggregation of the 2 measures. This would mean allocating the amount for
measure1 to all descendants of prduct.level1 and allocating the amount for
measure2 to all other members and then aggregating. Any ideas?

"Richard Tkachuk [MSFT]" wrote:

What do you want the calculation to show when you're at the all member
in
the product dimension? The way the calculation is set up, it will be
Measure2 - this your intent?

--
_______________
Disclaimer : This posting is provided "AS IS" with no warranties, and
confers no rights.

"Rob Anderson" <Rob Anderson (AT) discussions (DOT) microsoft.com> wrote in message
news:5EB61F54-4F13-4F8B-AC67-3F0713DAC894 (AT) microsoft (DOT) com...
Hi Guys,

We're having some problems with an MDX statement defining a calculated
member. What we have is a cube with 2 different measures. We would
like to
determine which measure to use based on one of the dimensions (lets
call
it
Products) .

The products dimension has 3 levels. Where the member is a descendant
of 1
of the members in the first level then we want to use measure1,
otherwise
use
measure2.

The MDX looks like this:

iif(Ancestor([Product].CurrentMember, [Product].[level1]) is
[Product].[Level1].&[9],

[Measures].[Measure1],
[Measures].[Measure2]
)

This all looks fine in a pivot table but when I put the dimension on
rows
and select 1 or more, but not all of the members in the dimension, the
grand
total for the measure is never correct. Usually it's whatever the
grandtotal
is for measure1 or measure2. Can anybody shed any light on this for
me?






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.