为什么 Order 会忽略子选择?
我在 Analysis Services 2005(和 2008 R2)中遇到了一些令人困惑的行为,如果有人能解释为什么会发生这种情况,我将不胜感激。为了解决这个问题,我重现了 Adventure Works 立方体的行为。
鉴于此 MDX:
SELECT [Customer].[Education].[(All)].ALLMEMBERS ON COLUMNS,
Order(DrillDownLevel({[Customer].[Customer Geography].[All Customers]}),
([Measures].[Internet Order Count]),
ASC) ON ROWS
FROM (SELECT {[Customer].[Education].&[Partial High School]} ON COLUMNS FROM [Adventure Works])
WHERE [Measures].[Internet Order Count];
查询使用行上的有序集进行计算:
所有客户:2, 136
德国:269
法国:298
加拿大:304
英国:311
美国:457
澳大利亚:497
但是,如果我在订单声明中使用的元组中包含教育的所有成员(或默认成员):
SELECT [Customer].[Education].[(All)].ALLMEMBERS ON COLUMNS,
Order(DrillDownLevel({[Customer].[Customer Geography].[All Customers]}),
([Measures].[Internet Order Count], [Customer].[Education].[All Customers]),
ASC) ON ROWS
FROM (SELECT {[Customer].[Education].&[Partial High School]} ON COLUMNS FROM [Adventure Works])
WHERE [Measures].[Internet Order Count];
然后该集合以明显不同的顺序返回:
所有客户:2, 136
法国:298
德国:269
英国:311
加拿大:304
澳大利亚:497
美国:459
请注意,法国和德国相对而言是无序的。与加拿大/英国和美国/澳大利亚相同。据我所知,它是在评估子多维数据集之前基于聚合进行排序的。
为什么包含此成员(它应该隐式地位于第一个示例中的元组中?)会导致顺序语句的计算看起来超出了子多维数据集的视觉总计? Filter 和 TopCount 等函数似乎具有相同的行为。
干杯。
I've run into some confusing behavior in Analysis Services 2005 (and 2008 R2) and would appreciate it if someone could explain why this is happening. For the sake of this question, I've reproduced the behavior against the Adventure Works cube.
Given this MDX:
SELECT [Customer].[Education].[(All)].ALLMEMBERS ON COLUMNS,
Order(DrillDownLevel({[Customer].[Customer Geography].[All Customers]}),
([Measures].[Internet Order Count]),
ASC) ON ROWS
FROM (SELECT {[Customer].[Education].&[Partial High School]} ON COLUMNS FROM [Adventure Works])
WHERE [Measures].[Internet Order Count];
The query evaluates with the ordered set on rows:
All Customers: 2, 136
Germany: 269
France: 298
Canada: 304
United Kingdom: 311
United States: 457
Australia: 497
However, if I include the All Member (or defaultmember) for Education in the tuple used in the order statement:
SELECT [Customer].[Education].[(All)].ALLMEMBERS ON COLUMNS,
Order(DrillDownLevel({[Customer].[Customer Geography].[All Customers]}),
([Measures].[Internet Order Count], [Customer].[Education].[All Customers]),
ASC) ON ROWS
FROM (SELECT {[Customer].[Education].&[Partial High School]} ON COLUMNS FROM [Adventure Works])
WHERE [Measures].[Internet Order Count];
Then the the set comes back in a significantly different order:
All Customers: 2, 136
France: 298
Germany: 269
United Kingdom: 311
Canada: 304
Australia: 497
United States: 459
Note that France and Germany are out of order relative to each other. Same with Canada / UK and with USA / Australia. From what I can tell, it's ordering based on the aggregation before the sub-cube is evaluated.
Why does including this member (which should implicitly be in the tuple in the first example?) cause the evaluation of the order statement to look outside of the subcube's visual totals? Filter and TopCount etc functions seem to have the same behavior.
Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的猜测是,由于这两个属性仅通过键相关(不存在直接关系),因此属性的交叉连接导致关键成员被聚合,这就是不应用视觉总计的地方(这是如何计算的方法之一)与子选择的非视觉总计)。
我构建了一个查询来演示交叉连接所发生的情况:
编辑:
这是另一个查询,表明一旦您使用查询作用域集(众所周知的解决方案)解决子选择问题,表达式就可以正确地使用属性覆盖:
感谢 Boyan 在 Twitter 上发布了这个问题。
问候, 赫尔沃耶
My guess is that since the 2 attributes are related only by key (no direct relationship exists) the resulting crossjoin of the attributes results on the key members being aggregated and this is where the visualtotals is not applied (it's one of the ways how to calculate tho nonvisualtotal with subselects).
I've constructed a query to demonstrate what is happening as a result of that crossjoin:
EDIT:
Here is another query that shows that the expression works correctly with attribute overwrites once you solve the subselect problem using a query scoped set (well-known solution):
Thanks to Boyan for tweeting this question.
Regards, Hrvoje
注意:请查看 http://www.bp- msbi.com/2011/07/mdx-subselects-some-insight/ 我在其中更详细地解释了该行为。
关于子选择的一篇很棒的文章是 Mosha 的 2008 MDX:在非可视模式下进行子选择和 CREATE SUBCUBE
请注意,当您使用子选择。隐式存在并应用视觉总计。这里关于您所经历的情况的关键信息是:
2。即使在表达式中,如果没有坐标覆盖,也会将视觉总计应用于物理度量值。
在您的第一个查询中,SSAS 默认应用视觉总计。您可以将查询更改为不这样做,如下所示:
SELECT 语句中的 NON VISUAL 关键字告诉 SSAS 仅应用隐式 Exists,而不应用可视总计部分。查询的结果将与第二种情况相同,但您还将看到其排序所依据的实数。
由于您在第二个查询中显式覆盖 All 成员,因此 SSAS 不会将可视总计应用于此表达式,并按所有年份的总额进行排序。但是,在评估非视觉总计的顺序后,它仍然显示所选 ROWS 度量的视觉总计。
Note: Have a look at http://www.bp-msbi.com/2011/07/mdx-subselects-some-insight/ where I explained the behaviour in more detail.
A great article about subselects is Mosha's 2008 MDX: subselects and CREATE SUBCUBE in non-visual mode
Note what happens when you use a subselect. Implicit Exists and visual totals are applied. The key bit of information here in regards to what you are experiencing is:
2. Applies visual totals to the values of physical measures even within expressions if there are no coordinate overwrites.
In your first query SSAS applies visual totals by default. You can change your query to not do this like this:
The NON VISUAL keyword in a SELECT statement tells SSAS to only apply the implicit Exists, but not the visual totals part. The results of the query will be the same as in the second case, but you will also see the real numbers it is ordering by.
Because you are explicitly overwriting the All member in the second query, SSAS does not apply the visual totals to this expression and orders by the total amounts for all years. However, it still displays the visual totals for the selected on ROWS measure after it evaluates the order on non-visual totals.
我不是 SSAS 专家,但这与 属性覆盖。
您将覆盖 Order 函数评估中的子选择。请注意,此行为取决于上下文(轴评估、计算成员和枢轴)。在您的示例中,上下文是轴评估期间的函数。该行为与枢轴的评估不同(一旦您知道轴)。这很复杂,但就是这样。
请注意,在 icCube 中,在与一些 MDX 专家讨论后,我们决定简化而不遵循此行为:子选择过滤器始终是应用。
I'm not a SSAS specialist but this is related to attribute overwrite.
You're overwriting your sub-select in the Order function evaluation. Note, this behavior is context dependent (axes eval, calculated members and pivot). In you example the context is a function during the evaluation of the axis. The behavior is different from the evaluation of the pivot (once you're axes are known). It's complicated but the way it is.
Note that in icCube and after discussing with some MDX specialist we decided to simplify and not follow this behavior: subselect filter is always applied.