1

我有一个看起来像这样的交叉连接

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]

我希望能够根据参数动态删除 Groups 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]

这样的事情可能吗?

4

1 回答 1

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

Iif由于元数据问题,您必须为函数的 false 分支包含 All 成员。

于 2011-12-16T17:06:42.853 回答