我有一个看起来像这样的交叉连接
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]
我希望能够根据参数动态删除Group In Rows中的交叉连接,以便在伪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 :(得分:0)
由于您使用@UseGroups
表示法,我假设您正在引用Reporting Services参数。
您可以为查询使用表达式,并根据参数构建查询:
="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]"
由于元数据问题,您必须将{All}成员包含在Iif
函数的false分支中。