MDX:如何聚合具有相同名称的层次结构级别成员

发布于 2024-08-25 05:19:30 字数 660 浏览 2 评论 0原文

您好,

我是 MDX 新手,无法理解如何在具有相同名称的成员的层次结构级别上执行聚合。此查询特定于 Microsoft Analysis Services 2000 多维数据集。

我有一个给定的层次结构维度,其级别定义如下:

[Segment].[Flow].[Segment Week]

[Segment Week] 级别内,我有以下成员:

[Week- 1]
[Week- 2]
[Week- 3]
   ...
[Week- 1]
[Week- 2]
[Week- 3]

这些成员具有相同的名称,但与不同的 [ 对齐Flow] 在父级别。因此,第一次出现的 [Week- 1] 成员与 [Flow].[A] 对齐,而第二次出现的 [Week- 1]< /code> 与 [Flow].[B] 对齐。我想要做的是聚合 [Segment Week] 级别内具有相同名称的所有成员。用 SQL 术语来说,我想按 [Segment Week] 级别内的成员名称进行分组。我不确定该怎么做。谢谢。

戴夫

Greetings,

I am new to MDX, and am having trouble understanding how to perform an aggregation on a hierarchy level with members that have the same names. This query is particular to Microsoft Analysis Services 2000 cubes.

I have a given hierarchy dimension with levels defined as follows:

[Segment].[Flow].[Segment Week]

Within the [Segment Week] level, I have the following members:

[Week- 1]
[Week- 2]
[Week- 3]
   ...
[Week- 1]
[Week- 2]
[Week- 3]

The members have the same names, but are aligned with a different [Flow] in the parent level. So, the first occurrence of the [Week- 1] member aligns with [Flow].[A] while the second occurrence of [Week- 1] aligns with [Flow].[B]. What I am trying to do is aggregate all the members within the [Segment Week] level that have the same name. In SQL terms, I want to GROUP BY the member names within the [Segment Week] level. I am unsure how to do this. Thank you.

Dave

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

傲鸠 2024-09-01 05:19:30

我认为你的立方体设计有缺陷。

设计维度的最佳方法是使其所有成员都是唯一的,并且聚合路径遵循维度的自然层次结构。

您可以从 SEGMENT 中删除 WEEK 级别并创建另一个维度(如果我没记错的话,在 AS 2000 中不能有多个层次结构),例如 WEEK,具有以下结构:

[Week].[Week- 1]
[Week].[Week- 2]
[Week].[Week- 3]
etc

然后您只需按 SEGMENT 和按星期。
例如,要获取 Flow A 的所有 Week1,您需要执行以下操作:

SELECT {[Measures].members} on 0 
FROM MYCUBE
WHERE ([Week].[Week- 1],[Segment].[A])

I think your cube design is flawed.

The best way to design a dimension is so all its members are unique, and the aggregation path follows the natural hierarchy of the dimension.

You could remove the WEEK level from SEGMENT and create another dimension (if I remember correctly, you can't have more than one hierarchy in AS 2000), say WEEK, with the following structure:

[Week].[Week- 1]
[Week].[Week- 2]
[Week].[Week- 3]
etc

Then you just have to filter by SEGMENT and by Week.
For example, to get all the Week1 of Flow A you'd do:

SELECT {[Measures].members} on 0 
FROM MYCUBE
WHERE ([Week].[Week- 1],[Segment].[A])
×眷恋的温暖 2024-09-01 05:19:30

可以用一下会员的钥匙吗?

[Week].&[1] ([Week].[Week - 1] (flow1)) 
[Week].&[5] ([Week].[Week - 1] (flow2))

作为参考,在 2008 年的“Adventure Works DW Standard Ed”立方体中,客户 Aaron A. Allen 的键是 [Customer].[Customer].&[20075]

UPDATE:
抱歉,请重新阅读您的问题,看起来您并没有尝试让特定的一周达到流程,您想要聚合它们。像这样的 CASE 语句怎么样:

CASE
  WHEN [Week].CURRENTMEMBER.NAME='Week - 1'
  THEN [Week].CURRENTMEMBER
  ELSE 0
END

不是很通用或灵活,但它可能是一个开始......

Could you use the key of the member?

[Week].&[1] ([Week].[Week - 1] (flow1)) 
[Week].&[5] ([Week].[Week - 1] (flow2))

For reference, in the 'Adventure Works DW Standard Ed' Cube for 2008, the key for Customer Aaron A. Allen is [Customer].[Customer].&[20075]

UPDATE:
Sorry, just reread your question, it looks like you're not trying to get the specific week to a flow, you want to aggreagate them. What about a CASE Statement like this:

CASE
  WHEN [Week].CURRENTMEMBER.NAME='Week - 1'
  THEN [Week].CURRENTMEMBER
  ELSE 0
END

Not very generic or flexible, but it might be a start...

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