0

我是 MDX 新手,我有以下情况。我必须计算特定部门(产品维度)、特定商店(位置维度)和特定时间范围内的收入。

我的立方体级别如下。
Product <- Department <- Item
Location <- Region <- Store
Time <- Year <- Month <-Day

说我是否有以下成员

[Product].[Dairy].[Oak Farm]
[Product].[Dairy].[GV]

[Location].[US West].[LA]
[Location].[US West].[CA]

[Time].[2015].[01].[01] : [Time].[2015].[02].[01]


然后我应该得到结果,因为 Product 中应该只包含 GV 而 location 应该只包含 CA

2015-01-01        US West       Dairy       $100
2015-02-01        US West       Dairy       $100

任何帮助,将不胜感激。

4

2 回答 2

1

一种非常简单的方法。@Whytheq 提供了更好的解决方案。

SELECT      
      (
       [Product].[Dairy].[GV]* 
       {[Time].[2015].[01].[01] : [Time].[2015].[02].[01]}*
       [Location].[US West].[CA]
      ) ON 1,
[Measures].Revenue ON 0
FROM [YourCube]
于 2015-05-29T10:30:40.320 回答
0

可能有几种方法,具体取决于具体要求。

 SELECT 
   [Measures].[SomeCubeMeasure] ON 0,      
   {[Time].[2015].[01].[01] : [Time].[2015].[02].[01]}*
    Exists
    (
      [Location].[Region].MEMBERS
     ,[Location].[US West].[CA]
    )*
    Exists
    (
      [Product].[Department].MEMBERS
     ,[Product].[Dairy].[GV]
    ) ON 1
FROM [yourCube];

编辑

要创建仅查看某些商店的度量,您可以使用以下内容:

 WITH MEMBER [Measures].[Store1and2Measure] AS
    Aggregate
    (
      {
        [Store][Region1][Store1]
       ,[Store][Region1][Store2]
      }
     ,[Measures].[SomeCubeMeasure]
    )       
 SELECT 
   [Measures].[Store1and2Measure] ON 0,      
   [Location].[US West].[LA] ON 1
FROM [yourCube];
于 2015-05-28T08:35:42.990 回答