SQL 2008 - 使用父聚合进行 MDX 叶级计算

发布于 2024-08-20 09:06:31 字数 235 浏览 3 评论 0原文

创建计算度量来计算自定义方差公式的最佳方法是什么(我无法使用默认的方差函数,因为它不适应自定义权重)。因此,叶级别公式将具有 2 个组件,一个组件将是叶级别的事实,另一个组件将是层次结构中各个级别的父聚合。所以公式如下:(需要在每个叶级别计算)

(ab)^2

其中 a 是叶级事实 [Measure].[Score] b 是父级别聚合([Dim].[Level].[All]、[Measure].[MeanScore])

What is the optimal way to create a calculated measure to compute a custom variance formula (I cannot use the default Variance function because it does not accommodate custom weights). So the leaf level formula will have 2 components one component will be a fact at the leaf level and the other component will be a parent aggregate at various levels in the hierarchy. So the formula is as follows: (Need this computed at each leaf level)

(a-b)^2

Where
a is a leaf level fact [Measure].[Score]
b is a parent level aggregate ([Dim].[Level].[All], [Measure].[MeanScore])

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泡沫很甜 2024-08-27 09:06:31

我能够通过将 CELL CALCULATION 与 CalculationPassValue 结合使用来解决这个问题:

CELL CALCULATION SDCalc
 FOR '([Dim].[Level].[Leaf], [Measures].[SD])'
  AS 'CalculationPassValue(([Measures].[Score] - [Measures].[MeanScore])^2, 1)', CONDITION = 'NOT IsEmpty([Measures].[FactCount])'

I was able to address this by using CELL CALCULATION in conjunction with CalculationPassValue:

CELL CALCULATION SDCalc
 FOR '([Dim].[Level].[Leaf], [Measures].[SD])'
  AS 'CalculationPassValue(([Measures].[Score] - [Measures].[MeanScore])^2, 1)', CONDITION = 'NOT IsEmpty([Measures].[FactCount])'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文