在MDX查询中分组

时间:2012-08-03 14:30:25

标签: join ssas mdx cross-join

我是MDX世界的新手..

我想基于3行对列进行分组。但是,还需要加入第4排...... 我的疑问是:

SELECT 
 (    { 
   [Measures].[Live Item Count] 
          } 
 ) DIMENSION PROPERTIES parent_unique_name ON COLUMNS, 


 Crossjoin(
 crossjoin(

  [Item].[Class].&[Light],
  [Item].[Style].&[Fav]
  [Item].[Season Year].members),
  [Item].[Count].children )    on rows
FROM Cube

输出如下:

Light(Row) | FAV(Row) | ALL(Row)  | 16(Row) | 2(col)
Light(Row) | FAV(Row) | ALL(Row)  | 7(Row)  | 1(col)
Light(Row) | FAV(Row) | 2012(Row) | 16(Row)| 2(col)
Light(Row) | FAV(Row) | 2011(Row) | 7(Row) | 1(col)

但是,我希望我的输出显示为:

Light(Row) | FAV(Row) | ALL(Row)  |        | 3(col)
Light(Row) | FAV(Row) | 2012(Row) | 16(Row)| 2(col)
Light(Row) | FAV(Row) | 2011(Row) | 7(Row) | 1(col)

即,我想将前两行分组,以便第3列中没有重复的'ALL'。

提前致谢

2 个答案:

答案 0 :(得分:0)

尝试这一点 - 使用级别名称Season Year,使用属性名称Season Year将获取每个成员,而不是所有成员:

SELECT 
 (    { 
   [Measures].[Live Item Count] 
          } 
 ) DIMENSION PROPERTIES parent_unique_name ON COLUMNS, 


 Crossjoin(
 crossjoin(

  [Item].[Class].&[Light],
  [Item].[Style].&[Fav]
  [Item].[Season Year].[Season Year].members),
  [Item].[Count].children )    on rows
FROM Cube

答案 1 :(得分:0)

如果[Item].[Count]层次结构中有所有成员,则可以使用此查询:

SELECT {[Measures].[Live Item Count]} DIMENSION PROPERTIES parent_unique_name ON COLUMNS, 
Crossjoin(
  Crossjoin([Item].[Class].&[Light], [Item].[Style].&[Fav]),
  Union(
    Crossjoin({"All member of [Item].[Season Year]"}, {"All member of [Item].[Count]"}),
    Crossjoin(Except([Item].[Season Year].members, {"All member of [Item].[Season Year]"}), [Item].[Count].children),
  ) ON ROWS
FROM Cube