通过通用计算量度进行排序会导致无限递归吗? (MDX) [英] Ordering by a generic calculated measure results in infinite recursion? (MDX)
问题描述
我需要编写一个计算得出的度量,该度量应显示与任何给定维度的总和相比,Measure1
的份额.我设法做到了:
I need to write a calculated measure that would show a share of Measure1
comparing to the total sum by any given dimension. I managed to do it like this:
CREATE MEMBER CURRENTCUBE.[Measures].[Test] AS
[Measures].[Measure1] / ( AXIS( 1 ).ITEM( 0 ).DIMENSION.LEVELS( 0 ).ITEM( 0 ), [Measures].[Measure1] )
但是,由于[Test]
的一般性质,因此无法通过此度量对尺寸进行排序.
But due to the generic nature of [Test]
, it is not possible to order a dimension by this measure.
SELECT [Measures].[Measure1] ON 0,
ORDER( [Dimension1].MEMBERS, [Measures].[Test] ) ON 1
FROM [MyCube]
执行上述代码会导致以下错误:
Executing the above code results in the following error:
检测到无限递归.依赖关系的循环是:测试->测试.
Infinite recursion detected. The loop of dependencies is: Test -> Test.
这很合逻辑-要获取AXIS( 1 ).ITEM( 0 )
,我们需要在轴1上有一组维成员,但是只有在对这些成员按[Test]
进行排序之后,才能获得该维成员.
Which is rather logical — to get AXIS( 1 ).ITEM( 0 )
, we need a set of dimension members on axis 1, but this set is impossible to obtain until the members are sorted by [Test]
.
另一方面,如果我将[Test]
定义为特定于某个尺寸,则它会按预期工作:
On the other hand, if I define [Test]
as specific to some dimension, it works as expected:
CREATE MEMBER CURRENTCUBE.[Measures].[Test] AS
[Measures].[Measure1] / ( [Dimension1].[All], [Measures].[Measure1] )
之所以可行,是因为[Dimension1].[All]
寻址特定成员,而无需轴1首先评估其成员集.
It works, because [Dimension1].[All]
addresses a particular member, without requiring axis 1 to evaluate its member set first.
是否有一种方法可以使此计算得出的度量通用?也许有可能以其他方式获取当前维度的[All]
成员吗?
Is there a way to make this calculated measure generic? Maybe, it's possible to get current dimension's [All]
member in another way?
推荐答案
如果仅显示一个度量,则可以重写第一个查询以避免错误:
If you are only displaying one measure, you could rewrite your first query to avoid the error:
SELECT [Measures].[Measure1] ON 0,
ORDER([Dimension1].MEMBERS) ON 1
FROM [MyCube]
WHERE ([Measures].[Test])
这篇关于通过通用计算量度进行排序会导致无限递归吗? (MDX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!