2011-12-16 51 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功能的假分支中的所有成員,因爲元數據問題。