2011-12-16 43 views
1

我有一个交叉连接,看起来像这样MDX - 使用IIF影响套在CROSSJOIN

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] 

我希望能够根据参数动态地去除组的交叉连接在行,以便在伪mdx我们会有

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] 

是这样的可能吗?

回答

0

由于您使用的@UseGroups符号,我假设你指的报表服务参数。

您可以使用表达式的查询,并构建查询的问候参数:

="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]" 

您必须包括为Iif功能的假分支中的所有成员,因为元数据问题。