MDX随时间计算(年 - 不是一年内)

我希望能够累计多年来对产品的承诺数量 - 每年新承诺的数据如下:
Year    | Count of new commitments | (What I'd like - count of new commitments to date)  
1986    4        4  
1987    22       26  
1988    14       40  
1989    1        41  
我知道在一年之内你可以做年初至今,月初等,但我需要多年来做。 给我前两列的mdx(非常简单 - 但我不知道从哪里开始):
select [Measures].[Commitment Count] on 0
, [Date Dim].[CY Hierarchy].[Calendar Year] on 1
from [Cube]
任何帮助都会很棒     
已邀请:
在MDX中的一些东西:
with member [x] as sum( 
    [Date Dim].[CY Hierarchy].[Calendar Year].members(0) : [Date Dim].[CY Hierarchy].currentMember,
    [Measures].[Commitment Count] 
)

select [x] on 0, [Date Dim].[CY Hierarchy].[Calendar Year] on 1 from [Cube]
    
使用公用表表达式:
with sums (year,sumThisYear,cumulativeSum) 
as (
    select year
         , sum(commitments) as sumThisYear
         , sum(commitments) as cumulativeSum
      from theTable
     where year = (select min(year) from theTable)
     group by year
     union all
    select child.year
         , sum(child.commitments) as sumThisYear
         , sum(child.commitments) + parent.cumulativeSum as cumulativeSum
      from sums par
      JOIN thetable Child on par.year = child.year - 1
     group by child.year,parent.cumulativeSum
)
select * from sums
在parent.cumulativeSum上进行分组时有一些“技巧”。我们知道这对于所有行都是相同的值,我们需要将它添加到sum(child.commitments),所以我们将它分组,以便SQL Server让我们引用它。这可能会被清除,以消除可能被称为“气味”的东西,但它会起作用。 警告:晚上11点15分,在我的脑海中,我可能需要一两次调整。 编辑:在锚子句中忘记了组,添加了     

要回复问题请先登录注册