我有一些计算成员的MDX查询,而不是我在SSMS中运行它们的速度非常快。 但是当我在立方体中实现这些计算成员并运行它们时,它的速度非常慢。 有这种行为的想法吗?
这是在SSMS中顺利运行的查询,但是当我从Excel或Tableau查询多维数据集(对立方体中相同的计算成员)时,它会花费很长时间
with member [Measures].[Sales BUM Avg 3Months]
as
sum(
lastperiods(3, ancestor([Date].[Calendar].currentMember,[Date]. [Calendar].[Calendar Year Month])), [Measures].[Sales Month BUM]
)
/
count(
nonempty(lastperiods(3, ancestor([Date].[Calendar].currentMember,[Date].[Calendar].[Calendar Year Month])), [Measures].[Sales Month BUM])
)
member [Measures].[CoverageSalesBUM]
as
sum([Measures].[Unrestricted BUM])
/
sum([Measures].[Sales BUM Avg 3Months] )
select non empty { [Measures].[Unrestricted BUM] , [Measures].[Sales BUM Avg 3Months] } on 0
,non empty([Date].[Calendar].[Calendar Date] , [Plant].[Plant].[Plant],[Material].[Material].[Material].[149249] ) on 1
from [InventCoverage]
答案 0 :(得分:0)
(更多的代码审查而非答案,因为我对多维数据集脚本知之甚少,因此无法评论您可能需要对多维数据集执行的操作)
您是第一次计算而不是重新发明函数Avg
吗?
另外在你的第二次计算中你为什么需要申请Sum()
?如果这是多维数据集中的聚合集,则无需明确说出Sum
。显然Divide
是最近的介绍,可能略微提高效率
WITH
MEMBER [Measures].[Sales BUM Avg 3Months] AS
Avg
(
LastPeriods
(3
,Ancestor
(
[Date].[Calendar].CurrentMember
,[Date].[Calendar].[Calendar Year Month]
)
)
,[Measures].[Sales Month BUM]
)
MEMBER [Measures].[CoverageSalesBUM] AS
Divide
(
[Measures].[Unrestricted BUM]
,[Measures].[Sales BUM Avg 3Months]
)
SELECT
NON EMPTY
{
[Measures].[Unrestricted BUM]
,[Measures].[Sales BUM Avg 3Months]
} ON 0
,NON EMPTY
(
[Date].[Calendar].[Calendar Date]
,[Plant].[Plant].[Plant]
,[Material].[Material].[Material].[149249]
) ON 1
FROM [InventCoverage];