Anchky's Tech Blog
专注.NET 专注BI
尽最大的努力,以求更好!

这是我翻译Chris Webb的文章,原文请查看http://spaces.msn.com/cwebbbi/blog/cns!7B84B0F2C239489A!710.entry?txtName=anchky&blogcs=end。主要介绍如何处理同时聚合多个计算成员!翻译的不一定正确,如有疑问的请查看原文!    
    多时间维度(根据AS 2005,确切的说是关于时间的属性层次)是非常有效的。我最初是从各种信息渠道介绍的
George Spofford的《mdx解决方案》知道多时间维度的。并且George Spofford和他的书提供的技术已经成为普遍应用于多维数据集分析服务的设计技巧之一。而且更进一步地,多时间维度技巧已经成为《增加商业智能》向导一书的设计时间智能平台的组成部分。

     那么,这里头又没有什么新的东西值得介绍呢?很多时候,多时间维度就是比单时间维度高效。拿如下的mdx脚本举例子,这个mdx是根据向导创建的,创建了单一时间维度[Year-Month Period Calculations]山的两个计算成员(Year-To-Date and Year-Over-Year Growth)

/*

  Begin Time Intelligence script for the [Period].[Year-Month] hierarchy.

*/

 Create Member

  CurrentCube.[Period].[Year-Month Period Calculations].[Year to Date]

  As "NA" ;

  Create Member

  CurrentCube.[Period].[Year-Month Period Calculations].[Year Over Year Growth]

  As "NA" ;   

Scope(

       {

         [Measures].[Sales]

       }

) ;

 // Year to Date

  (

    [Period].[Year-Month Period Calculations].[Year to Date],

    [Period].[Year].[Year].Members,

     [Period].[Month].Members

  ) =

  Aggregate(

             { [Period].[Year-Month Period Calculations].DefaultMember } *

             PeriodsToDate(

                            [Period].[Year-Month].[Year],

                            [Period].[Year-Month].CurrentMember

             )

  ) ;

// Year Over Year Growth 

  (

     [Period].[Year-Month Period Calculations].[Year Over Year Growth],

    [Period].[Year].[Year].Members ( 1 ) : Null,

     [Period].[Month].Members

  ) =     

  ( [Period].[Year-Month Period Calculations].DefaultMember ) -

  ( [Period].[Year-Month Period Calculations].DefaultMember,

    ParallelPeriod(

                    [Period].[Year-Month].[Year],

                    1,

                    [Period].[Year-Month].CurrentMember

    )

  ) ;

   (

    [Period].[Year-Month Period Calculations].[Year Over Year Growth],

    [Period].[Year].[Year].Members ( 0 ),

    [Period].[Month].Members

  ) = Null ;

 End Scope ;

 

/*

  End Time Intelligence script for the [Period].[Year-Month] hierarchy.*/

    这样做是高效的,但是当你的用户要求能够在Year-To-Date的数据上查看Year-Over-Year的增长趋势的时候,我们该怎么办?当然,你可以通过创建第三个计算成员来实现这个功能。然而我们很容易想到:当需求的计算聚合越多,我们创建一维持功能的计算成员数量就会越多。

    而这些刚好是多用途的时间属性层次可以解决的,因为多时间维度可以帮助你控制计算成员的爆发式增长———你可以让多个计算成员集合在一起。首先,必须像创建初始时间属性层次一样通过拖拽列在时间维度上创建一个新的属性层次。需要注意的是,要确保把是否聚集(IsAggregatable)属性设置为false以免聚合所有成员。接下来要确定的是,哪个计算对应与哪个层次,当然该计算必须指向可用的计算聚合。如下的的mdx修改了上述的mdx,修改之后,两个计算成员分别指向了两个不同的属性层次,这两个层次分别是[Period].[Year-Month Period Calculations] [Period].[Year-Month Period Calculations2]

/*

  Begin Time Intelligence script for the [Period].[Year-Month] hierarchy.

*/

 Create Member

  CurrentCube.[Period].[Year-Month Period Calculations].[Year to Date]

  As "NA" ;

 Create Member

  CurrentCube.[Period].[Year-Month Period Calculations 2].[Year Over Year Growth]

  As "NA" ;

 Scope(

       {

         [Measures].[Sales]

       }

) ;

// Year to Date

  (

    [Period].[Year-Month Period Calculations].[Year to Date],

    [Period].[Year].[Year].Members,

     [Period].[Month].Members

  ) =

  Aggregate(

             { [Period].[Year-Month Period Calculations].DefaultMember } *

             PeriodsToDate(

                            [Period].[Year-Month].[Year],

                            [Period].[Year-Month].CurrentMember

             )

  ) ;

// Year Over Year Growth 

  (

     [Period].[Year-Month Period Calculations 2].[Year Over Year Growth],

    [Period].[Year].[Year].Members ( 1 ) : Null,

     [Period].[Month].Members

  ) =     

 

  ( [Period].[Year-Month Period Calculations 2].DefaultMember ) -

  ( [Period].[Year-Month Period Calculations 2].DefaultMember,

    ParallelPeriod(

                    [Period].[Year-Month].[Year],

                    1,

                    [Period].[Year-Month].CurrentMember

    )

  ) ;

   (

    [Period].[Year-Month Period Calculations 2].[Year Over Year Growth],

    [Period].[Year].[Year].Members ( 0 ),

    [Period].[Month].Members

  ) = Null ;

 End Scope ;

/*

  End Time Intelligence script for the [Period].[Year-Month] hierarchy.

*/

     这下用户就可以通过交叉他们要求的两个计算成员来实现通过Year-To-Date数据查看Year-Over-Year Growth,就跟单独使用单个计算成员一样。

 

posted on 2006-05-31 18:08  anchky  阅读(1996)  评论(0编辑  收藏  举报