Scope Statement 替代 Slow CrossJoin Count MDX

Scope Statement Alternative to Slow CrossJoin Count MDX

下面的 MDX 适合我的目的,但速度非常慢。是否有范围声明基本上我想计算总金额为 $>5000 的剩余交叉连接 contact/purchases 组合。

叉积总共有 290M 行,但我不确定如何以不同方式构建它以提高性能。感谢您的帮助。

 CREATE HIDDEN STATIC SET [Over 5K Plus Test 2] 
 AS NONEMPTY (([Contact].[Contact ID].[Contact ID],[Fund Sold].[Fund Sold ID].[Fund Sold ID]),
[Measures].[FA And Team Gross Sales with FAs Including All Vehicles]); 

CREATE MEMBER CURRENTCUBE.[Measures].[FA and Team Product Count]
AS COUNT(EXISTING((Filter([Over 5K Plus Test 2], [Measures].[FA And Team Gross Sales with FAs Including All Vehicles] >= 5000)))),

试试这个避免过滤器:

CREATE MEMBER CURRENTCUBE.[Measures].[FA and Team Product Count]
AS SUM(
 Existing [Contact].[Contact ID].[Contact ID].Members
 * Existing [Fund Sold].[Fund Sold ID].[Fund Sold ID].Members,
 IIF([Measures].[FA And Team Gross Sales with FAs Including All Vehicles] >= 5000, 1, Null)
);

如果仍然很慢,那么 post 后面的计算 FA And Team Gross Sales with FAs Including All Vehicles

实现此目的的更有效方法需要付出更多努力,但性能会更好,因为它避免了 Existing 函数。首先,您必须在 DSV 中创建一个列,该列是事实 table 中的计算列,使用此表达式:

CAST(null as int)

然后在此列上创建一个名为“FA 和团队产品计数”的新度量。展开列绑定并选择 NullHandling=Preserve。这必须是物理度量而不是计算度量,因为只有物理度量的范围分配才会聚合。

然后将以下语句添加到 MDX 脚本(而不是顶部提到的计算度量):

([Measures].[FA and Team Product Count],
 [Contact].[Contact ID].[Contact ID].Members,
 [Fund Sold].[Fund Sold ID].[Fund Sold ID].Members) =
 IIF([Measures].[FA And Team Gross Sales with FAs Including All Vehicles] >= 5000, 1, Null);