MDX:关于推进查询的建议

时间:2012-12-18 15:45:48

标签: sql-server-2008 ssas mdx

我有一个可用的MDX语句,但我想扩展它。当前的声明带回了特定年份的前10名,其中行是州,而列是总收入。我想生产5列 - 每列和行集代表不同的年份。我将如何实现这一目标?

  with
  member measures.[Total Earnings] as 
  (measures.[Total GS]) + (measures.[Total DE]) + (measures.[Total SE])
    set [Top 10 States] as
    topcount 
  (
    {Stores.[State Code]. [State Code].members},
     10,
     (Measures.[Total Earnings], [Time].[C Year].[2011])
  )
  select
   {([Measures].[Total  Earnings])} on columns,
     {[Top 10 States]} on rows
    from LoyaltyMeasurements
     Where (Time.[C Year].[2011]);

1 个答案:

答案 0 :(得分:0)

我认为您正在寻找的功能是ParallelPeriod

MEMBER measures.[Total Earnings Prev1] as 
    Aggregate(
    ParallelPeriod([Time].[C Year], 1, [Time].CurrentMember),
    (measures.[Total GS]) + (measures.[Total DE]) + (measures.[Total SE])
    )