locked
How do I achieve Cumulative Sums for a set in MDX? RRS feed

  • General discussion

  • [This is just for sharing information for those common asked questions collected from forums. If you have any better way or feedback, please directly reply in this thread so that community users can benefit from your answers.]


    Answer:
    Suppose there is a named set [SortedCus], if you want to get the cumulative sums for each member, then you can try the sample below against the sample database [Adventure Works]:
     
    WITH
    SET [SortedProduct] AS
    Order
    (
    [Product].[Product].[Product]
    ,[Measures].[Internet Sales Amount]
    ,BDESC
    )
    MEMBER [Measures].[Cumulative Sums] AS
    Sum
    (
    Head
    (
    [SortedProduct]
    ,Rank
    (
    [Product].[Product].CurrentMember
    ,[SortedProduct]
    )
    )
    ,[Measures].[Internet Sales Amount]
    )
    SELECT
    {
    [Measures].[Internet Sales Amount]
    ,[Measures].[Cumulative Sums]
    } ON 0
    ,[SortedProduct] ON 1
    FROM [Adventure Works];


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Tuesday, June 22, 2010 9:33 AM