作用域声明替代慢速交叉联接计数MDX

时间:2019-01-18 19:27:40

标签: ssas mdx

下面的MDX可以达到我的目的,但是速度非常慢。是否有作用域声明本质上,我想计算总金额为$> 5000的剩余交叉联接联系人/购买组合。

交叉产品总共有2.9亿行,但是我不确定如何以不同的方式构造此行以提高性能。谢谢您的帮助。

 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)))),

1 个答案:

答案 0 :(得分:1)

尝试避免使用过滤器的方法:

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)
);

如果仍然很慢,则将计算结果发布到FA And Team Gross Sales with FAs Including All Vehicles

之后

完成此操作的更有效方法需要更多的精力,但会避免使用Existing函数,因此会表现更好。首先,您必须使用以下表达式在DSV中创建一列,这是事实表中的计算列:

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);