Question

I have a crossjoin that looks like this

SELECT  
  {[Measures].[Respondent Count]} ON COLUMNS
 ,{
      [Groups In Rows].[Group].ALLMEMBERS*
      [Questions In Rows].[By ShortCode].[Option].ALLMEMBERS*
      [Questions In Columns].[By ShortCode].[Option].ALLMEMBERS
  } ON ROWS
FROM [cube]

I want to be able to dynamically remove the crossjoin on Groups In Rows according to a parameter so that in pseudo mdx we would have

SELECT  
  {[Measures].[Respondent Count]} ON COLUMNS
 ,
IIF(@UseGroups = "yes",
{     [Groups In Rows].[Group].ALLMEMBERS*
      [Questions In Rows].[By ShortCode].[Option].ALLMEMBERS*
      [Questions In Columns].[By ShortCode].[Option].ALLMEMBERS
  },
{
      [Questions In Rows].[By ShortCode].[Option].ALLMEMBERS*
      [Questions In Columns].[By ShortCode].[Option].ALLMEMBERS
} ON ROWS
FROM [Cube]

Is anything like this possible?

Was it helpful?

Solution

Since you use the @UseGroups notation, I'm assuming you're refering to a Reporting Services parameter.

You can use an expression for the query, and construct the query in regards to the parameter:

="SELECT { [Measures].[Respondent Count] } ON COLUMNS, "
&"       { "
& Iif(@UseGroups = "yes",
      "[Groups In Rows].[Group].ALLMEMBERS*",
      "[Groups In Rows].[Group].All")
&"         [Questions In Rows].[By ShortCode].[Option].ALLMEMBERS* "
&"         [Questions In Columns].[By ShortCode].[Option].ALLMEMBERS "
&"       } ON ROWS "
&"  FROM [Cube]"

You have to include the All member for the false branch of the Iif function, because of metadata problems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top