使用MDX将SSAS成员分组到存储桶中

时间:2015-12-30 21:20:39

标签: ssas mdx

SSAS和MDX新手在这里。

如果我有一个带有Geography的SSAS多维数据集,则将Product作为维度和总销售量作为度量。

以下元素属于地理位置:

EAST
WEST
NORTH
SOUTH
MID-ATLANTIC
MOUNTAIN
NORTH-WEST

产品是:

1
2
3
4

对于产品ID = 1,有没有办法可以将一些成员分组到该国的其他地方"桶和聚合销售?

意思是,预期的输出是:

Product ID    Geography          Sales

1             East              100
1             West              200
1             North             300
1             South             400
1             RestOfNation      1200

2             East              100
2             West              50
2             RestOfNation      1500

有没有办法让一些成员屈服于#34; RestOfNation"使用MDX查询?

1 个答案:

答案 0 :(得分:1)

你可以尝试这样的事情。

  1. 创建一个由您想要放入存储桶RestOfWorld的成员组成的命名集。
  2. 在地理维度内成为成员,即其他世界成员的聚合。
  3. 查找不在世界其他地方的国家/地区。
  4. 这是一个针对AdvWrks的脚本(值得安装,因为它是使用mdx并发布到论坛时的常用原型工具):

    WITH 
      SET [RestOfWorld] AS 
        {
          [Customer].[Customer Geography].[Country].&[United Kingdom]
         ,[Customer].[Customer Geography].[Country].&[Germany]
        } 
      MEMBER [Customer].[Customer Geography].[All].[RestOfWorld] AS 
        Aggregate
        (
          {
            [Customer].[Customer Geography].[Country].&[United Kingdom]
           ,[Customer].[Customer Geography].[Country].&[Germany]
          }
        ) 
      SET [CountriesMinusROW] AS 
        [Customer].[Customer Geography].[Country].MEMBERS - [RestOfWorld] 
    SELECT 
      NON EMPTY 
        {[Measures].[Internet Sales Amount]} ON 0
     ,NON EMPTY 
          [Product].[Category].[Category]
        * 
          {
            [CountriesMinusROW]
           ,[Customer].[Customer Geography].[All].[RestOfWorld]
          } ON 1
    FROM [Adventure Works]
    WHERE 
      [Date].[Calendar Year].&[2007];
    

    上面给出了以下cellset

    enter image description here