Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding (All) from sets

Tags:

ssas

mdx

I'm using the following but i think there's probably a much simpler method of excluding the All members from the results?

WITH 
    SET [Non_All_Distributors] AS
        {FILTER(
            [Distributor Name].members,
            (InStr(1, [Distributor Name].CurrentMember.NAME, "All") = 0) 
            )}
    SET [Non_All_Countries] AS
        {FILTER(
            [Geography Country].members,
            (InStr(1, [Geography Country].CurrentMember.NAME, "All") = 0) 
            )}
SELECT  
    NON EMPTY 
        [Dimension].[Hierarchy].DEFAULTMEMBER 
    ON COLUMNS, 

    NON EMPTY 
        [Non_All_Distributors]
        *
        [Non_All_Countries]
        *
        Tail([Date].[Date - Calendar Month].[Calendar Day].Members,60)  
        *  
        { 
        [Measures].[Revenue], 
        [Measures].[NumClients]
        } 
    ON ROWS 

FROM [OURCUBE]  
like image 471
whytheq Avatar asked Jul 21 '26 09:07

whytheq


1 Answers

Just use

SELECT  
    NON EMPTY 
        [Dimension].[Hierarchy].DEFAULTMEMBER 
    ON COLUMNS, 

    NON EMPTY 
        [dimension of Distributor Name].[Distributor Name].[Distributor Name].Members
        *
        [dimension of Geography Country].[Geography Country].[Geography Country].Members
        *
        Tail([Date].[Date - Calendar Month].[Calendar Day].Members,60)  
        *  
        { 
        [Measures].[Revenue], 
        [Measures].[NumClients]
        } 
    ON ROWS 

FROM [OURCUBE]  

There is no need to define sets here. you can directly state the distributor and country members in the rows clause.

By repeating the attribute name, you restrict the attribute hierarchy - which you refer to by [dim].[attrib name] to the level below the All member, which happens to have the same name as the attribute again. An attribute hierarchy has two levels: level 0 contains the 'All' member and level 1 all the members of the attribute. (This is true only if you did not do special configurations like setting the attribute as non aggregateabable, but I assume the standard case, as you have All members in your hierarchies.

Apart from being more simple, this statement will run much faster, as Filter is a real performance killer in many cases.

like image 105
FrankPl Avatar answered Jul 24 '26 06:07

FrankPl