需要 MDX 语句解释

MDX Statement explaination required

请解释下面的MDX语句-

Axis(1).Item(0).Item (0).Dimension.Levels(0).item(0)

如果可能,请也分享输出(使用 SSMS 分析服务)

Axis(1).Item(0).Item(0).Dimension.Levels(0).Item(0)

弄清楚这个表达式的含义的方法是从左到右遍历每个函数,并确定每个函数正在做什么和返回什么。让我们一次过一遍这个函数。

  1. Axis(1) - 检索行轴(索引 1 处的轴)上的元组集。

  2. Item(0) - 从先前返回的集合中检索第一个元组。

  3. Item(0) - 从先前返回的元组中检索第一个成员。

  4. 维度 - 从先前返回的成员获取层次结构。

  5. Levels(0) - 从先前返回的层次结构中检索第一个级别。

  6. Item(0) - 从先前返回的层级检索第一个成员。

这是我用来创建上述列表的 Microsoft 函数定义。

Axis()

Returns the set of tuples on a specified axis.

Item(Tuple)

Returns a tuple from a set.

Item(Member)

Returns a member from a specified tuple.

Dimension

Returns the hierarchy that contains a specified member, level, or hierarchy.

Levels()

Returns the level whose position in a dimension or hierarchy is specified by a numeric expression or whose name is specified by a string expression.


编辑 - 添加示例

从 Adventure Works 多维数据集检查地理维度和层次结构。

地理层次结构有 5 个级别。

  • [地理].[地理].[(全部)]
  • [地理].[地理].[国家]
  • [地理].[地理].[州-省]
  • [地理].[地理].[城市]
  • [地理].[地理].[邮政编码]

让我们在列轴上使用您的表达式(通过计算成员)并在行轴上使用 select 城市亚历山大港。

WITH
    MEMBER [Measures].[SomeMember] AS AXIS(1).ITEM(0).ITEM(0).DIMENSION.LEVELS(0).ITEM(0).MEMBER_CAPTION
SELECT 
    {([Measures].[SomeMember])} ON COLUMNS,
    {([Geography].[Geography].[City].&[Alexandria]&[NSW])} ON ROWS
FROM 
    [Adventure Works]

这里是对正在发生的事情的分解:

  1. Axis(1) - Returns 来自行轴的集合:
    {([Geography].[Geography].[City].&[Alexandria]&[NSW])}

  2. ITEM(0) - Returns 集合的第一个元组:
    ([Geography].[Geography].[City].&[Alexandria]&[NSW])

  3. ITEM(0) - Returns 元组的第一个成员:
    [Geography].[Geography].[City].&[Alexandria]&[NSW]

  4. DIMENSION - Returns 成员的维度层次结构:
    [Geography].[Geography]

  5. LEVELS(0) - Returns 层次结构的第一层:
    [Geography].[Geography].[(All)]

  6. ITEM(0) - returns 该级别的第一个成员:
    [Geography].[Geography].[(All)].[All Geographies]

查询结果如下:

这是一个屏幕截图,可帮助直观显示 All Geographies 成员相对于 Alexandria 成员的位置: