简体   繁体   中英

How to sum next periods in MDX

I've created this calculated member to sum next periods and it's quite slow. Instead if I do the same thing for the past previous periods with LastPeriods calculation, it runs smoothly. Any ideas why it's happening? Is there any other function for next periods?

WITH 
MEMBER [Measures].[Avg Dmd BUM 4Months] 
AS 
   Avg(  
      {([Date].[Calendar].currentMember,[Measures].[Dmd Fcst BUM])
      ,([Date].[Calendar].currentMember.lead(1),[Measures].[Dmd Fcst BUM])
      ,([Date].[Calendar].currentMember.lead(2),[Measures].[Dmd Fcst BUM])
      ,([Date].[Calendar].currentMember.lead(3),[Measures].[Dmd Fcst BUM])
     }
   )     

Maybe try the more traditional format for Avg - with a second argument:

Avg(  
      {[Date].[Calendar].currentMember
      ,[Date].[Calendar].currentMember.lead(1)
      ,[Date].[Calendar].currentMember.lead(2)
      ,[Date].[Calendar].currentMember.lead(3)
     }
  ,[Measures].[Dmd Fcst BUM]
   ) 

You could use lag with negative numbers and also the range operator ':'

Avg(  
      [Date].[Calendar].currentMember: [Date].[Calendar].currentMember.lag(-3)
     ,[Measures].[Dmd Fcst BUM]
   ) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM