MDX - 需要第3个维度示例

时间:2016-05-09 15:42:19

标签: ssas mdx

我正在尝试学习MDX。我是一位经验丰富的SQL开发人员。

我正在尝试查找具有两个以上维度的MDX查询的示例。每个讨论MDX的网页都提供了简单的二维示例链接:

#import "MyViewController.h"

@implementation MyViewController

- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Uncomment to override the CDVCommandDelegateImpl used
        // _commandDelegate = [[MyCommandDelegate alloc] initWithViewController:self];
        // Uncomment to override the CDVCommandQueue used
        // _commandQueue = [[MyCommandQueue alloc] initWithViewController:self];
    }
    return self;
}

- (id)init
{
    self = [super init];
    if (self) {
        // Uncomment to override the CDVCommandDelegateImpl used
        // _commandDelegate = [[MyCommandDelegate alloc] initWithViewController:self];
        // Uncomment to override the CDVCommandQueue used
        // _commandQueue = [[MyCommandQueue alloc] initWithViewController:self];
    }
    return self;
}


@end

@implementation MyCommandDelegate

#pragma mark CDVCommandDelegate implementation

- (id)getCommandInstance:(NSString*)className
{
    return [super getCommandInstance:className];
}

- (NSString*)pathForResource:(NSString*)resourcepath
{
    return [super pathForResource:resourcepath];
}

@end

@implementation MyCommandQueue

- (BOOL)execute:(CDVInvokedUrlCommand*)command
{
    return [super execute:command];
}

@end

我正在寻找使用以下别名的示例:PAGES(第三维?),部分(第四维?)和章(第五维?)。我试过这个,但我不认为这是正确的:

select 
{[Measures].[Sales Amount]} on columns,
Customer.fullname.members on rows
from [Adventure Works DW2012]

我正在尝试使用MDX查询获取此输出(这来自AdventureWorks DW2012):

enter image description here

2 个答案:

答案 0 :(得分:3)

这不是屏幕截图中的三维结果集,除非有从中裁剪的内容。

这样的东西
SELECT [Geography].[Country].Members ON 0,
[Customer].[CustomerName].Members ON 1
FROM [whatever the cube is called]
WHERE [Measures].[Sales Amount]

(维度/层次结构/级别名称可能不完全正确) 会给出一个像你的消息中那样的结果集。

我所知道的任何客户端工具都没有使用超越二维的维度和维度名称。 (其他人可能知道不同)。它们似乎存在于MDX中,因此MDX可以将> 2维结果集交给可以处理它们的客户端(例如,将其结果交给主查询的MDX子查询)。

MDX中经常使用的技巧是通过交叉连接将两个维度的成员放在一个轴上:

选择 {[日期]。[日历日期]。[日历年]。成员* [地理位置]。[国家]。成员} ON 0, [别的] ON 1 来自[立方体]

答案 1 :(得分:3)

以下情况如何 - 它不会将超过两个维度发送回平面屏幕,但它使用了很多维度明确

SELECT 
  [Measures].[Sales Amount] ON O,
  [Customer].[fullname].MEMBERS ON 1
FROM
( 
  SELECT
    [Date].[Calendar Month].[Calendar Month].&[February-2012] ON 0,
    [Geography].[Country].[Country].&[Canada] ON 1,
    [Product].[Product].&[Red Bike] ON 2,
    [Customer].[Customer].&[foo bar] ON 3
  FROM [Adventure Works DW2012]
)

我已经构成了维度|层次结构|成员组合,因为我无权访问多维数据集。

此外,如果我们考虑隐式维度,请执行以下操作:

SELECT 
  [Customer].[Location].[Customer Geography]  ON 0,
  [Customer].[fullname].[fullname].&[Aaron Flores] ON 1
FROM [Adventure Works DW2012]
WHERE 
  (
   [Measures].[Sales Amount]
  );

在切片器上,我使用了大括号(..)来表示tuple,但这实际上是以下内容的缩写:

SELECT 
  [Customer].[Location].[Customer Geography]  ON 0,
  [Customer].[fullname].[fullname].&[Aaron Flores] ON 1
FROM [Adventure Works DW2012]
WHERE 
  (
   [Measures].[Sales Amount]
  ,[Date].[Calendar Month].[Calendar Month].[All],
  ,[Geography].[Country].[Country].[All],
  ,[Product].[Product].[All]
  ,...
  ,...
  ....
  );

多维数据集中每个维度的All成员都可以包含在此切片器中,而不会影响结果。

因此mdx的整体性质是多维的 - 是的,你得到的不仅仅是一个二维表返回到你的屏幕,但你到达那个单元集的方式可能涉及很多维度。