Skip to content

Instantly share code, notes, and snippets.

@marpontes
Created September 27, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marpontes/0a8d33cc3bd7fd2066a4 to your computer and use it in GitHub Desktop.
Save marpontes/0a8d33cc3bd7fd2066a4 to your computer and use it in GitHub Desktop.
Some crazy MDX Demonstration to my fellow friend @maialson

WITH MEMBER [Measures].[one] as 1 MEMBER [Measures].[condic] as iif( inStr([Customers].currentMember.name,"a")>0, 0,[Measures].[one]) MEMBER [Measures].[Sequential] as rank( [Customers].currentMember, extract( nonEmptyCrossjoin( nonEmptyCrossjoin( [Territory].currentMember, [Customers].[Customer].members ), [Product].currentMember ), [Customers] )

    )
    
MEMBER [Measures].[Total] as 
    count(
            nonEmptyCrossjoin(
                nonEmptyCrossjoin(
                    [Territory].currentMember,
                    [Customers].[Customer].members
                ),
                [Product].currentMember
            )
    )
    
MEMBER [Measures].[MeasureIf] as 
    iif([Measures].[condic]=0,[Measures].[Sequential],0)
    
MEMBER [Measures].[AcumIf] as 
    sum(
        
            extract(nonEmptyCrossjoin(
                nonEmptyCrossjoin(
                    [Territory].currentMember,
                    [Customers].[Customer].members
                ),
                [Product].currentMember
            ),[Customers]).item(0) : 
            extract(nonEmptyCrossjoin(
                nonEmptyCrossjoin(
                    [Territory].currentMember,
                    [Customers].[Customer].members
                ),
                [Product].currentMember
            ),[Customers]).item([Measures].[Sequential]-1)
        

          ,
        [Measures].[MeasureIf]
    )

            
MEMBER [Measures].[Last AcumIf] as 
    max(
            nonEmptyCrossjoin(
                nonEmptyCrossjoin(
                    [Territory].currentMember,
                    [Customers].[Customer].members
                ),
                [Product].currentMember
            ),
            [Measures].[AcumIf]
    )

SELECT nonEmptyCrossjoin( nonEmptyCrossjoin( [Markets].Children, [Product].Children ), [Customers].children ) ON ROWS,

{
    [Measures].[Quantity],
    [Measures].[Sequential],
    [Measures].[condic],
    [Measures].[Total],
    [Measures].[MeasureIf],
    [Measures].[AcumIf],
    [Measures].[Last AcumIf]
}
ON COLUMNS

from [SteelWheelsSales]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment