简体   繁体   中英

ssas cumulative sum of months

I would like to cumulative sum the months as a measure in the cube. For example: if i select month 1 the result of SumofMonths must be 1. If i select month 11 the result must be 11. In the Wide World Importers DW is this what i've got:

CREATE DYNAMIC SET [Wide World Importers DW].[Selected Months] as ( 
    [Delivery Date].[Calendar].[Calendar Month Label] 
) ;

CREATE MEMBER [Wide World Importers DW].[Measures].[Months Count] AS (
count( [Selected Months] )
)

CREATE MEMBER [Wide World Importers DW].[Measures].[SumOfMonths] AS (
sum(Existing [Months Count] )
)

SELECT  
{[Measures].[Measures].[Sales Amount With Tax]
,[Measures].[SumOfMonths]
} on 0 
from ( 
    SELECT ( 
        {[Delivery Date].[Calendar].[Calendar Month Label].&[CY2016-Dec]

        }) 
    ON COLUMNS  FROM [Wide World Importers DW]
) 

The result of the last query is 1 because i filter only 1 month. But i want the result 12 because i select month 12 (cumulative). Can somebody help me?

Thanks!

I am not an MDX expert so I wont try to give answer with a query. It looks like you're trying to calculate cumulative measure, maybe this will be helpful?:

https://support.microsoft.com/en-us/help/301637/inf-how-to-calculate-the-cumulative-value-of-a-measure

If you do not have the same month numbers in your date dimension I would guess that you need either add them (can be hidden) or to count the months from start of the year, similar to how days have been counted here:

https://www.sqlservercentral.com/Forums/Topic1619121-17-1.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM