質問

I have a tuple set that I want to AGGREGATE .

For example: I have this query:

Select {[Sales Territory].[Sales Territory].DEFAULTMEMBER.children} on 0,
{[Sales Reason].[Sales Reason Type].DEFAULTMEMBER.children} on 1 
From [Adventure Works]

When I want to add a TOTAL for one of the axis I do this:

WITH MEMBER [Sales Territory].[Sales Territory].[Total X] as 'AGGREGATE(AXIS(0))' 
Select {[Sales Territory].[Sales Territory].[Total X],[Sales Territory].[Sales Territory].DEFAULTMEMBER.children} on 0
,{[Sales Reason].[Sales Reason Type].DEFAULTMEMBER.children} on 1 From [Adventure Works]

Now, for now it's all good. But when I'm trying to aggregate a cross join set it's failed. Please take this query as an example:

Select {[Sales Territory].[Sales Territory].DEFAULTMEMBER.children} on 0
,{[Sales Reason].[Sales Reason Type].DEFAULTMEMBER.children}*{[Sales Channel].[Sales Channel].DEFAULTMEMBER.children} on 1 
From [Adventure Works]

Please notice that I did a cross join between [Sales Reason].[Sales Reason Type] to [Sales Channel].[Sales Channel]

Is there a way to do a total on axis when there are more than one member?

Thanks!

P.S: I'm a newbie with MDX queries

役に立ちましたか?

解決

You are doing things more complex than necessary. Your second query should be simplified to:

Select [Sales Territory].[Sales Territory].Members on 0,
       [Sales Reason].[Sales Reason Type].DEFAULTMEMBER.children on 1
  From [Adventure Works]

Please note that the All member is already a member of (nearly) all hierarchies in MDX. Thus, to include the All members for the third query, you could either write

Select {[Sales Territory].[Sales Territory].Members}
       on 0,
       {[Sales Reason].[Sales Reason Type].Members}
       *
       {[Sales Channel].[Sales Channel].Members}
       on 1 
  From [Adventure Works]

or, if you really wanted to have the Total of the Axis only without the combinations of the Totals from one of the hierarchies with the other members of the other one, union two sets - one with the tuple containing of the All members, and one with the cross join of the other two hierarchies. I am using the short form of Union here - which is the + operator for sets:

Select {[Sales Territory].[Sales Territory].Members}
       on 0,
       { ([Sales Reason].[Sales Reason Type].All, [Sales Channel].[Sales Channel].All) }
       +
       (
          {[Sales Reason].[Sales Reason Type].[Sales Reason Type].Members}
          *
          {[Sales Channel].[Sales Channel].[Sales Reason Type].Members}
       )
       on 1 
  From [Adventure Works]
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top