简体   繁体   English

MDX查询中的用户定义的层次结构

[英]User defined hierarchy in an MDX query

Following on from this question regarding calculating a member I have 2 calculated members defined as: 这个有关计算成员的问题开始,我有2个计算的成员定义为:

MEMBER [Asset].[Class].[Fixed Income Derivatives]
AS
AGGREGATE(
    {
       [Asset].[Class].&[Fixed Income],
       [Asset].[Sub Class].&[Derivatives]
    },
    [Measures].CurrentMember
)
MEMBER [Asset].[Class].[Fixed Income Non-derivatives]
AS
AGGREGATE(
    {
      [Asset].[Class].&[Fixed Income],
      EXCEPT([Asset].[Sub Class].[Sub Class],[Asset].[Sub Class].&[Derivatives])
    },
    [Measures].CurrentMember
)

I can use these in an MDX query as follows: 我可以在MDX查询中使用它们,如下所示:

SELECT
  {
   [Measures].[Market Value]
  } ON 0,
  NON EMPTY
  { 
   [Asset].[Class].[Fixed Income Derivatives],
   [Asset].[Class].[Fixed Income Non-derivatives]
   [Asset].[Class].[Class]
  } ON 1
  FROM [Asset]

And this gives me output as follows: 这给了我如下输出:

Class-----------------------|-MarketValue
============================|=============
Fixed Income Derivatives    | 12345
Fixed Income Non-derivatives| 54321
Fixed Income                | 66666
Property                    | 123
Equity                      | 987

Note that the first 2 rows are actually constituant parts of Row 3. Now, I can do some magic with the client code which reads this data to turn that table into a hierarchy, but - and here's the question - can I do it using MDX? 请注意,前2行实际上是第3行的组成部分。现在,我可以对客户端代码进行一些魔术处理,该客户端代码读取该数据以将该表转换为层次结构,但是-这是问题-我可以使用MDX来完成吗? Or am I just complicating things? 还是我只是使事情复杂化? Im not adverse to making changes in the cube if necessary, or if I could define this hierarchy there. 我对在必要时在多维数据集中进行更改并不不利,或者可以在其中定义此层次结构。

AFAIK, you can't use MDX to get a result that is supposed as hierarchy at the client side without some magic with the client code or changing the cube structure. AFAIK,如果没有客户端代码的任何魔术或更改多维数据集结构,则无法使用MDX获得在客户端被视为层次结构的结果。 Even though you can find a trick to fake the client the result as an hierarchy i don't suggest you to go that way. 即使您可以找到一种方法来伪造客户,但结果却是一个层次结构,我不建议您那样做。

Here is my suggestion. 这是我的建议。 If i understand correctly , you want to get a result that is kind of an unbalanced hierarchy tree that looks like below. 如果我正确理解的话 ,您希望得到一种类似于下面所示的不平衡层次树的结果。

[Asset].[Class] [资产]。[类别]

  • [Fixed Income] [固定收入]
    • [Asset].[Class].[Fixed Income Derivatives] [资产]。[类别]。[固定收益衍生物]
    • [Asset].[Class].[Fixed Income Non-Derivatives] [资产]。[类别]。[固定收益非衍生品]
  • Property 属性
  • Equity 公平

This kind of unbalanced trees can only be implemented by parent-child hierarchies. 这种不平衡的树只能由父子层次结构实现。

You can either try to balance the hierarchy by adding an intermediate level (or leaf levels) that includes Property and Equity members or create a parent-child hierarchy to achieve even deeper level unbalanced tree. 您可以尝试通过添加包括PropertyEquity成员的中间级别(或叶子级别)来平衡层次结构,或者创建父子层次结构以实现更深层次的不平衡树。

Edit 编辑

Here is an article about parent-child dimensions. 这是有关父子尺寸的文章

也许以这种方式添加计算成员:

WITH MEMBER [Asset].[Class].[Fixed Income].[Derivatives] AS ...

我最后只返回了Class和Sub Class,并在客户端代码中构建了层次结构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM