MDX:问题筛选导致Reporting Services查询中使用的MDX查询

时间:2010-03-18 00:00:39

标签: sql-server reporting-services mdx

为什么我的[结果层次结构]中的成员不会通过下面的filter()声明返回我的结果?

    SELECT 
    NON EMPTY {[Measures].[Group Count], [Measures].[Overall Group Count]   } ON COLUMNS,
    NON EMPTY {
        [Survey].[Surveys By Year].[Survey Year].ALLMEMBERS * 
        [Response Status].[Response Status].[Response Status].ALLMEMBERS} 
    DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM (
    SELECT ( { [Survey Type].[Survey Type Hierarchy].&[9] } ) ON COLUMNS
    FROM (
        SELECT ( { [Response Status].[Response Status].[All] } ) ON COLUMNS
        FROM (
            SELECT ( STRTOSET(@SurveySurveysByYear, CONSTRAINED) ) ON COLUMNS
            FROM (
            SELECT(filter([Group].[Group Hierarchy].members, instr(@GroupGroupFullName,[Group].[Group Hierarchy].Properties( "Group Full Name" )))) on columns 
            FROM [SysSurveyDW]))))

CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

2 个答案:

答案 0 :(得分:1)

这是 解决方案,按预期工作。将过滤器移动到WHERE子句......这不起作用UNTIL我把“SELECT({[Group]。[Group]。[Group]})ON COLUMNS ...”FROM中的代码。

有谁能看到更好的方法来实现这一目标?绝对不是这里的MDX大师:)

SELECT 
    NON EMPTY {[Measures].[Group Count], [Measures].[Overall Group Count]   } ON COLUMNS,
    NON EMPTY { 
        STRTOSET(@SurveySurveysByYear) * 
        [Response Status].[Response Status].[Response Status].ALLMEMBERS}
    DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM (
    SELECT ({[Group].[Group].[Group]}) ON COLUMNS 
    FROM (
        SELECT ( { [Survey Type].[Survey Type Hierarchy].&[9] } ) ON COLUMNS
        FROM (
            SELECT ( { [Response Status].[Response Status].[All] } ) ON COLUMNS
            FROM [SysSurveyDW] )))
where
filter([Group].[Group Hierarchy].members - [Group].[Group Hierarchy].[All],
 instr(@GroupGroupFullName,[Group].[Group Hierarchy].Properties( "Group Full Name" )))


CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

答案 1 :(得分:0)

我认为你的参数可能错误。编码的方式,它有效地查找参数中存在的成员名称。我不确定你作为参数传递了什么,但我认为你更有可能搜索包含参数值的成员名称。