Monday, February 20, 2012

MDX OR condition

Hi,

How could i have an OR condition to retrieve something like this.....

sum(Measure1 for condition 1 or condition 2...) and there is an And of dimension members in the condition

if it was only an And of dim members....sum(measure, dim1.xyz, dim2.xyz) would do

This is to be used inside a Calculation in a cube in AS 2000.

Regards

Hello:

Here you have the queries for foodmart2000 cube.

if the "or condition" is related to the same dimension, you can use sth like this:

with
set [ConditionSet] as 'filter([Promotions].DefaultMember.Children,[Promotions].CurrentMember.Name="Dollar Days" or [Promotions].CurrentMember.Name="Mystery Sale" )'
member [Promotions].[ConditionSum] as 'sum([ConditionSet],([Education Level].[Bachelors Degree],[Gender].[M],[Measures].[Profit])) '
select { [Promotions].[ConditionSum]} on axis(0) from [sales]


if the "or condition" is related to two different dimensions, you can use sth like this:

with member [Measures].[MaleProfit] as '([Gender].[M],[Measures].[Profit])'
member [Measures].[GraduteProfit] as '([Education Level].[Graduate Degree],[Measures].[Profit])'
member [Measures].[MaleOrGraduateProfit] as '[Measures].[MaleProfit]+ [Measures].[GraduteProfit]'
member [Measures].[MaleAndGraduateProfit] as '([Education Level].[Graduate Degree],[Gender].[M],[Measures].[Profit])'
select { [Measures].[MaleOrGraduateProfit],[Measures].[MaleAndGraduateProfit]} on axis(0) from [sales]

I hope this helps
Regards
Maciej Kiewra

|||

Hi Guys:

I made the error in the [Measures].[MaleOrGraduateProfit].

As you probably rember from your math class card(AUB)=card(A)+card(B)-card(A*B)

therefore:

sum(AUB)=sum(A)+sum(B)-sum(A*B)

The only thing that has changed is [Measures].[MaleOrGraduateProfit] definition.

with member [Measures].[MaleProfit] as '([Gender].[M],[Measures].[Profit])'
member [Measures].[GraduteProfit] as '([Education Level].[Graduate Degree],[Measures].[Profit])'
member [Measures].[MaleAndGraduateProfit] as '([Education Level].[Graduate Degree],[Gender].[M],[Measures].[Profit])'
member [Measures].[MaleOrGraduateProfit] as '[Measures].[MaleProfit]+ [Measures].[GraduteProfit]-[Measures].[MaleAndGraduateProfit]'

select { [Measures].[MaleOrGraduateProfit],[Measures].[MaleAndGraduateProfit]} on axis(0) from [sales]

Regards and sorry for the stupid mistake

No comments:

Post a Comment