如何在SSAS中计算MDX中的全年

时间:2015-05-12 15:12:38

标签: ssas mdx

我正在使用内置时间智能功能,我想计算全年的措施 例如,如果当前日期成员是2015/03/01;我希望从2015/01/01到2015/12/31有一个计算的度量。

CREATE MEMBER CurrentCube.[DimTime].[FY-FQ-FM DimTime Calculations].[Full Year] AS "NA" ; 
( 
  [DimTime].[FY-FQ-FM DimTime Calculations].[Year to Date]
, [DimTime].[Fiscal Year].[Fiscal Year].Members
, [DimTime].[Date].Members
, { [Measures].[Forecasts], [Measures].[Budget] } 
) 
= Aggregate( 
   { [DimTime].[FY-FQ-FM DimTime Calculations].[Current DimTime] } 
     * PeriodsToDate( 
         [DimTime].[FY-FQ-FM].[Fiscal Year]
       , [DimTime].[FY-FQ-FM].CurrentMember
       ) 
   ) ;

1 个答案:

答案 0 :(得分:0)

感谢@whytheq和@AkshayRane的帮助。 我能够在下面使用全年。

(
    [DimTime].[FY-FQ-FM DimTime Calculations].[Full Year],
    [DimTime].[Fiscal Year].[Fiscal Year].Members,
    [DimTime].[Date].Members,
    {
      [Measures].[Forecasts],
      [Measures].[Budget]
    }

)


=

  Aggregate(
             { [DimTime].[FY-FQ-FM DimTime Calculations].[Current DimTime] } 
             *

            PeriodsToDate(
                            [DimTime].[FY-FQ-FM].[Fiscal Year],
                           (
                            ANCESTOR(  
                                      [DimTime].[FY-FQ-FM].CURRENTMEMBER,
                                      [DimTime].[FY-FQ-FM].[Fiscal Year] 
                                    )
                           )
                        )
          )