Filter by multiple members of an hierarchy

RASMiranda picture RASMiranda · Jun 14, 2013 · Viewed 7k times · Source

So lets say i have this MDX query:

select 
    NON EMPTY {([Dim 1].[Member 1].[Member 1])} on columns
    ,NON EMPTY {([Dim 2].[Member 2].[Member 1])} on rows
from [Cube 1]
where
{(
    [Dim 3].[Hierarchy 3].[Member 3].&[Value 3]
    ,[Measures].[Measure 1]
)}

But now i also need to filter, as i did with [Dim 3].[Hierarchy 3].[Member 3].&[Value 3], but with several member values of an hierarchy from a different dimensionn, lets call them:

[Dim 4].[Hierarchy 4].[Member 4].&[Value 2]
[Dim 4].[Hierarchy 4].[Member 4].&[Value 4]
[Dim 4].[Hierarchy 4].[Member 4].&[Value 8]

I've tried this:

select 
    NON EMPTY {([Dim 1].[Member 1].[Member 1])} on columns
    ,NON EMPTY {([Dim 2].[Member 2].[Member 1])} on rows
from [Cube 1]
where
{(
    [Dim 3].[Hierarchy 3].[Member 3].&[Value 3]
    ,[Dim 4].[Hierarchy 4].[Member 4].&[Value 2]
    ,[Dim 4].[Hierarchy 4].[Member 4].&[Value 4]
    ,[Dim 4].[Hierarchy 4].[Member 4].&[Value 8]
    ,[Measures].[Measure 1]
)}

Got this:

The 'Hierarchy 4' hierarchy appears more than once in the tuple.

Also tried this (i know, not much sense in here):

select 
    NON EMPTY {([Dim 1].[Member 1].[Member 1])} on columns
    ,NON EMPTY {([Dim 2].[Member 2].[Member 1])} on rows
from [Cube 1]
where
{(
    [Dim 3].[Hierarchy 3].[Member 3].&[Value 3]
    ,[Dim 4].[Hierarchy 4].[Member 4].&[Value 2]
    :[Dim 4].[Hierarchy 4].[Member 4].&[Value 4]
    :[Dim 4].[Hierarchy 4].[Member 4].&[Value 8]
    ,[Measures].[Measure 1]
)}

And got this:

The : function expects a member expression for the 2 argument. A tuple set expression was used.

I'm fairly new to MDX (more experienced in T-SQL), don't even know what exactly to google, so bare with my dumbness.

Any help will be welcomed.

Thanks in Advance.

Answer

RASMiranda picture RASMiranda · Jun 15, 2013

Got it: http://msdn.microsoft.com/en-us/library/ms146047.aspx

If you want to use multiple members from the same hierarchy, you need to include a set in the WHERE clause

Another thing, in my example Dim 2 = Dim 3, so to get the result that i expect i need this:

select 
    NON EMPTY {([Dim 1].[Member 1].[Member 1])} on columns
    ,NON EMPTY 
       {(
          [Dim 2].[Hierarchy 3].[Member 3].&[Value 3] 
          ,[Dim 2].[Member 2].[Member 1]
       )} on rows
from [Cube 1]
where
(
    {
       [Dim 4].[Hierarchy 4].[Member 4].&[Value 2]
       ,[Dim 4].[Hierarchy 4].[Member 4].&[Value 4]
       ,[Dim 4].[Hierarchy 4].[Member 4].&[Value 8]
    }
    ,([Measures].[Measure 1])
)