包含来自同一层次结构的 2 个维度的 MDX 查询
我的多维数据集的相关结构是我有一个包含“类”和“子类”的层次结构。我还有一个名为“价值”的衡量标准,这就是我想要获得的。
一个简单的查询可能如下所示:
SELECT
NON EMPTY ([Measures].[Value]) ON COLUMNS,
NON EMPTY ([Some Dimension].[Class Hierarchy].[Class]) ON ROWS
FROM [MyCube]
我显然可以使用返回到 Adomd 的层次结构来读取子类。
我的问题是双重的,首先我如何“展平”这个层次结构以便接收类和子类作为单元集中的离散成员?这不起作用:
SELECT
NON EMPTY ([Measures].[Value]) ON COLUMNS,
NON EMPTY (
[Some Dimension].[Class Hierarchy].[Class],
[Some Dimension].[Class Hierarchy].[Sub Class]
) ON ROWS
FROM [MyCube]
Class Hierarchy 层次结构在 Crossjoin 函数中多次使用
,我实际需要做的是在特定类上过滤上述内容,同样,由于与上面相同的原因,这不会起作用。
SELECT
NON EMPTY ([Measures].[Value]) ON COLUMNS,
NON EMPTY (
{[Some Dimension].[Class Hierarchy].[Class].&[ClassA],[Some Dimension].[Class Hierarchy].[Class].&[ClassB]},
[Some Dimension].[Class Hierarchy].[Sub Class]
) ON ROWS
FROM [MyCube]
非常感谢任何帮助。 MDX 快把我逼疯了!
The relevant structures from my cube are that I have a Hierarchy with "Class" and "SubClass". I also have a Measure called "Value" which is what im trying to obtain.
A simple query may look like:
SELECT
NON EMPTY ([Measures].[Value]) ON COLUMNS,
NON EMPTY ([Some Dimension].[Class Hierarchy].[Class]) ON ROWS
FROM [MyCube]
And I can obviously read the SubClass using the HIerarchy which is returned to Adomd.
My issue is twofold, firstly how would I "flatten" this hierarchy so as to receive both Class and SubClass as discrete members in the CellSet? This does not work:
SELECT
NON EMPTY ([Measures].[Value]) ON COLUMNS,
NON EMPTY (
[Some Dimension].[Class Hierarchy].[Class],
[Some Dimension].[Class Hierarchy].[Sub Class]
) ON ROWS
FROM [MyCube]
The Class Hierarchy hierarchy is used more than once in the Crossjoin function
Second issue, what I actuually need to do is filter the above on particular classes, again this wont work for the same reason as above.
SELECT
NON EMPTY ([Measures].[Value]) ON COLUMNS,
NON EMPTY (
{[Some Dimension].[Class Hierarchy].[Class].&[ClassA],[Some Dimension].[Class Hierarchy].[Class].&[ClassB]},
[Some Dimension].[Class Hierarchy].[Sub Class]
) ON ROWS
FROM [MyCube]
Any help much appreciated. MDX is driving me nuts!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的维度上缺少 MEMBERS 属性。
对于您的第一个示例,请尝试以下操作:
对于第二个示例,请尝试以下操作:
You are missing the MEMBERS property on your dimension.
For your first example try this:
For your second example try this:
在 WHERE 子句中使用子查询。
MDX 将始终限制仅在一个轴上使用一维。
子查询是解决这个问题的一种方法。在MDX也让我发疯之后,我最近学会了这个技巧。
Use Subqueries in your WHERE Clause.
MDX will always restrict the use of one dimension on one Axis only.
Sub Query is a way to get around that. I recently learnt this trick after MDX drove me nuts as well..
嗨,这个查询对我有用。
请小心查询中的 where 子句中的“}”。
Hi this query worked for me.
Please be carefull with the '}' in the where clause as the query has.