Search code examples
ssasmdxmdx-query

Calculate Cumulative Month Value in MDX


I wanna calculate the cumulative values by month/year

My dimensions period as follow:

Period Dimension

I ve tried any ways to perform this operation, but unsucessfull

with member [Measures].[Valor Acumulado] 
as Sum(PeriodsToDate([Período].[Mês].[(All)]),[Measures].[Valor Pago]
)
 with member 
 [Measures].[Valor Acumulado] as Sum(YTD([Período].[Mês].[(All)]),
 [Measures].[Valor Pago])

Or the cumulative calcule does not work or appears a Error Message

CellOrdinal 1 VALUE #Error Query (2, 37) The YTD function expects a member expression for the argument. A string or numeric expression was used

Query execution Query execution

Is it necessary to make a concatenation with Year and Month members?

Anybody to help me?


Solution

  • Take a look at the sample below, it will help.

    with 
    member 
    [Measures].[Internet Sales AmountRunningtotal]
    as 
    case when [Measures].[Internet Sales Amount] = null then null 
    else 
    sum({[Product].[Subcategory].firstchild:[Product].[Subcategory].currentmember},[Measures].[Internet Sales Amount])
    end
    select {[Measures].[Internet Sales Amount],
    [Measures].[Internet Sales AmountRunningtotal]
    } on columns,
    
    non empty
    ([Date].[Calendar Year].[Calendar Year],[Date].[Calendar Quarter of Year].[Calendar Quarter of Year],
    [Product].[Category].[Category],[Product].[Subcategory].[Subcategory])
    on 
    rows 
    from 
    [Adventure Works]
    

    Result enter image description here