views:

422

answers:

2

Why aren't my results being filtered by the members from my [Group Hierarchy] returned via the filter() statment below?

    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
A: 

I think you may have your parameters around the wrong way. The way you have it coded, its effectively looking for members names that exist within your parameter. I'm not sure what you are passing in as the parameter, but I would have thought that it was more likely that you were searching for member names that contained the parameter value.

Darren Gosbell
The filter on the Group Hierarchy works fine (e.g. returns a SET of groups that are expected) ... its just that they aren't being used to restrict the results coming back for some reason.
wgpubs
Subselects work like query scoped subcubes, so unless your measures are calculations that depend on the current context they should work fine. If your measures are calculated measures, then the best solution would be to switch the query to using the WHERE clause instead of subselects.
Darren Gosbell
+1  A: 

Here is a solution that works as expected. Moved the filter into the WHERE clause ... which didn't work UNTIL I put the "SELECT ({[Group].[Group].[Group]}) ON COLUMNS..." code in the FROM.

Can anyone see a better way to accomplish this? Definitely not the MDX guru here :)

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
wgpubs