[英]Selecting all levels in a hierarchy as a tuple in MDX
I made my first cube yesterday. 我昨天做了第一个立方体。 I'm still new to this, so please forgive any misuse of terminology. 我对此还很陌生,因此请原谅任何滥用术语的行为。 One of my dimensions, let's call it MyDimension1
has a hierarchy, let's call it MyHierarchy
, with two levels, let's call them Level1
and Level2
. 我的一个维度,我们称其为MyDimension1
,它具有一个层次结构,我们称其为MyHierarchy
,它具有两个级别,分别称为Level1
和Level2
。
I seem to be able to do something like: 我似乎能够做类似的事情:
SELECT
{ [Measures].[Whatever] } ON 0,
{ ([MyDimension1].[Level1].[Level1], [MyDimension1].[Level2].[Level2]) } ON 1
FROM MyCube
Which gives me the result I want. 这给了我想要的结果。 If I understand correctly, the set defining axis 1 contains a tuple with two components(?). 如果我理解正确,则定义轴1的集合包含一个具有两个分量(?)的元组。 I've read that each component(?) of a tuple is supposed to be from a different dimension, but I seem to be able to specify components of the same dimension, as demonstrated by the above query. 我已经读过,元组的每个组件(?)都应该来自不同的维度,但是正如上面的查询所示,我似乎能够指定相同维度的组件。 I'd like to be able to just specify the hierarchy by name and then have the server create the tuples for me, though. 我希望能够仅通过名称指定层次结构,然后让服务器为我创建元组。 So something like: 所以像这样:
SELECT
{ [Measures].[Whatever] } ON 0,
{ AllLevelsToTuple([MyDimension1].[MyHierarchy]) } ON 1
FROM MyCube
But I can't seem to figure out how to do this. 但我似乎无法弄清楚该如何做。 Thanks in advance! 提前致谢!
EDIT (My example, as requested by an answerer): 编辑(我的示例,根据应答者的要求):
This does what I want, functionally, but isn't the syntax I'd like: 从功能上来说,这可以实现我想要的功能,但不是我想要的语法:
SELECT [Measures].[Original] ON 0,
([Customer].[Customer].[Customer], [Customer].[Account ID].[Account ID]) ON 1
Results (In SSMS): 结果(在SSMS中):
Original
--------- -- --------
CustomerA 15 306.03
CustomerA 16 754.20
...
CustomerB 17 524.43
...
CustomerC 22 760.42
...
When I expand the dimension, it looks like: 当我扩展尺寸时,它看起来像:
- Customer
- Hierarchy
+ Members
+ Customer
+ Account ID
When I do something like (I'd like to do something similar syntactically): 当我做类似的事情时(我想在语法上做类似的事情):
SELECT [Measures].[Original] ON 0,
([Customer].[Hierarchy].Members) ON 1
I get the following results: 我得到以下结果:
Original
---------- --------
All 17638.15
CustomerA 2624.76
15
16
...
CustomerB 3113.67
17 524.43
...
CustomerC 3427.01
22 760.42
...
I want there to be 3 columns, not 2, basically. 我希望基本上有3列,而不是2列。
You might want to read this MDX gentle introduction . 您可能需要阅读此MDX简要介绍 。
I've read that each component(?) of a tuple is supposed to be from a different dimension 我读过元组的每个组件(?)应该来自不同的维度
From different hierarchy instead. 来自不同的层次结构 。 In AS, I guess that for each level, you have as well a corresponding flat hierarchy; 在AS中,我想对于每个级别,您也都有一个对应的平面层次结构。 so the following looks like you're accessing levels of two different hierarchies: 因此,以下内容看起来像您正在访问两个不同层次结构的级别:
{ ([MyDimension1].[Level1].[Level1], [MyDimension1].[Level2].[Level2]) } ON 1
I'm not a specialist of AS but I guess the following statement : 我不是AS的专家,但我猜下面的说法:
SELECT [Measures].[Original] ON 0,
([Customer].[Customer].[Customer], [Customer].[Account ID].[Account ID]) ON 1
is actually interpreted as a crossjoin of level members from 2 different hierarchies; 实际上被解释为来自2个不同层次的级别成员的交叉联接; it is more likely that the () notation is interpreted as the () operator instead of tuple notation and then {},{} is a crossjoin in MDX : ()表示法更有可能被解释为()运算符,而不是元组表示法,然后{},{}是MDX中的交叉连接:
SELECT [Measures].[Original] ON 0,
[Customer].[Customer].[Customer].members * [Customer].[Account ID].[Account ID].members ON 1
hence the two columns in front of your measures in the result. 因此,结果中位于您的度量前面的两列。
I want there to be 3 columns, not 2, basically. 我希望基本上有3列,而不是2列。
You'll need to use calculated measures; 您将需要使用经过计算的度量; something like : 就像是 :
with
MEMBER Measures.HN as [Customer].Currentmember.Hierarchy.Name
MEMBER Measures.LN as [Customer].Currentmember.Level.Name
MEMBER Measures.MN as [Customer].Currentmember.Name
SELECT { Measures.HN, Measures.LN, Measures.MN, [Measures].[Original] } ON 0,
([Customer].[Hierarchy].Members) ON 1
Yes, you can create a tuple from different dimensions, and you do so by placing members between parentheses and separated by commas. 是的,您可以从不同的维度创建元组,并且可以通过将成员放在括号之间并用逗号分隔来实现。
But in this case, you don't need a tuple, simply a set. 但是在这种情况下,您不需要一个元组,只需一个集合。 A set contains members from a single dimension, separated by commas and placed between curly braces: {}. 一组包含单个维度中的成员,这些成员之间用逗号分隔并放在花括号{}之间。
Have a look at the descendants function. 看看后代功能。 You can create a set from your hierarchy using this function. 您可以使用此功能从层次结构中创建一个集合。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.