Exponential moving average in MDX

Viewed 52
1 Answers

According to The Formula, You Can Try Below Calculated Measures:

[A1]: Case WHEN [MeasureName] = Null THEN 0 ELSE 1 END
[A2]: CASE WHEN A1 = 0 THEN Null ELSE SUM(Null:[DimDateTime].[Year_Month_Day].CurrentMember,[A1]) END
[A3]: 0.5 --For Example For (1-Alpha)
[A4]: [MeasureName] * ([A3]^[A2]) --For Numerator of a Fraction
[A5]: CASE WHEN [MeasureName] = Null THEN Null ELSE (A3^A2) END --For Denominator of a Fraction
[A6]: CASE WHEN ISEMPTY([A4]) THEN NULL ELSE
      SUM 
      (
         TAIL
          (
            FILTER
            (
             {
               [DimDateTime].[Year_Month_Day].CurrentMember.lag(100):[DimDateTime].[Year_Month_Day].CurrentMember --You Can Change Value 100 Depend on Your Data
             } , not isempty ([A4])
            )
           ,3  -- You Can Change This Value Depend on Your Business
          ),
            [A4]
       )
       END
[A7]: CASE WHEN ISEMPTY([A5]) THEN NULL ELSE
      SUM 
      (
         TAIL
          (
            FILTER
            (
             {
               [DimDateTime].[Year_Month_Day].CurrentMember.lag(100):[DimDateTime].[Year_Month_Day].CurrentMember --You Can Change Value 100 Depend on Your Data
             } , not isempty ([A5])
            )
           ,3  -- You Can Change This Value Depend on Your Business
          ),
            [A5]
       )
       END
[A8]: [A6]/[A7]

Related