gpt4 book ai didi

mdx - MDX 中的指数移动平均线

转载 作者:行者123 更新时间:2023-12-05 05:49:03 25 4
gpt4 key购买 nike

我有下面的立方体输出

date          value
---- -----------
2021-01-06 10
2021-01-07 Null
2021-01-08 Null
2021-01-09 15
2021-01-10 18
2021-01-11 25

我的问题是,如何使用没有任何 Null 值的数据创建指数移动平均线。

https://social.msdn.microsoft.com/Forums/en-US/39f7074b-ca2d-435b-8612-1c71955b76a8/mdx-for-exponential-moving-average?forum=sqlanalysisservices

这对我来说是一个有用的解决方案,但它不会忽略任何 Null 值。

最佳答案

根据公式,您可以尝试以下计算的措施:

[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]

关于mdx - MDX 中的指数移动平均线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70719826/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com