包含来自同一层次结构的 2 个维度的 MDX 查询

发布于 2024-08-14 05:52:20 字数 996 浏览 9 评论 0原文

我的多维数据集的相关结构是我有一个包含“类”和“子类”的层次结构。我还有一个名为“价值”的衡量标准,这就是我想要获得的。

一个简单的查询可能如下所示:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

摘星┃星的人 2024-08-21 05:52:20

您的维度上缺少 MEMBERS 属性。

对于您的第一个示例,请尝试以下操作:

SELECT 
    NON EMPTY ([Measures].[Value]) ON COLUMNS,
    NON EMPTY {(
            [Some Dimension].[Class Hierarchy].[Class].MEMBERS,
            [Some Dimension].[Class Hierarchy].[Sub Class].MEMBERS)} ON ROWS
FROM [MyCube]

对于第二个示例,请尝试以下操作:

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].MEMBERS)} ON ROWS
FROM [MyCube]

You are missing the MEMBERS property on your dimension.

For your first example try this:

SELECT 
    NON EMPTY ([Measures].[Value]) ON COLUMNS,
    NON EMPTY {(
            [Some Dimension].[Class Hierarchy].[Class].MEMBERS,
            [Some Dimension].[Class Hierarchy].[Sub Class].MEMBERS)} ON ROWS
FROM [MyCube]

For your second example try this:

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].MEMBERS)} ON ROWS
FROM [MyCube]
旧伤慢歌 2024-08-21 05:52:20

在 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..

似狗非友 2024-08-21 05:52:20

嗨,这个查询对我有用。

 SELECT NON EMPTY { [Measures].[App Count] }
 ON COLUMNS, 
 NON EMPTY 
 {(
 EXISTING 
 (
 [MART TIME DIM].[Date].[Date] .MEMBERS) * 
 [New Ren DIM].[New Ren CODE].[New Ren CODE].ALLMEMBERS
 )}
 ON ROWS FROM [SubmissionCube]  
 where
({
[MART BROKER DIM].[BROKER ID].&[10812]},{[MART TIME DIM].[Year].&[2015],
{[MARTTIME DIM].[Year].&[2016]}
})  

请小心查询中的 where 子句中的“}”。

Hi this query worked for me.

 SELECT NON EMPTY { [Measures].[App Count] }
 ON COLUMNS, 
 NON EMPTY 
 {(
 EXISTING 
 (
 [MART TIME DIM].[Date].[Date] .MEMBERS) * 
 [New Ren DIM].[New Ren CODE].[New Ren CODE].ALLMEMBERS
 )}
 ON ROWS FROM [SubmissionCube]  
 where
({
[MART BROKER DIM].[BROKER ID].&[10812]},{[MART TIME DIM].[Year].&[2015],
{[MARTTIME DIM].[Year].&[2016]}
})  

Please be carefull with the '}' in the where clause as the query has.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文