MDX:两个分组的前 X 和两个组之一的前 Y (X>Y)

MDX: Top X by two groupings and Top Y (X>Y) by one of the two groups

我正在尝试编写一个查询,以显示基于 年份和产品 TOP 4 互联网销售额。同时,我试图显示 TOP 1 仅基于 的经销商销售额。

Year        Product          Internet Sales Amount      Reseller Sales Amount
CY 2015   Road-150 Red, 48        3,215                     ,021
CY 2015   Road-150 Red, 68        1,215                     ,021
CY 2015   Road-150 Red, 22         ,215                     ,021
CY 2015   Road-250 Red, 52         ,215                     ,021
CY 2014   Road-150 Red, 100       2,215                     ,021
CY 2014   Road-220 Black, 90      0,101                     ,021
CY 2014   Road-65 Blue, 28        9,465                     ,021
CY 2014   Road-86 Red, 33         0,001                     ,021

我编写了以下查询以实现按年份和产品排名前 4 的 Internet 销售额,但无法弄清楚如何将下一个度量添加到结果集中。

WITH 
  SET [TopSalesbyYearAndProd] AS 
    Generate
    (
      [Date].[Calendar Year].[Calendar Year].MEMBERS
     ,TopCount
      (
          [Date].[Calendar Year].CurrentMember
        * 
          [Product].[Product].[Product].MEMBERS
       ,4
       ,[Measures].[Internet Sales Amount]
      )
    ) 
SELECT 
  {[Measures].[Internet Sales Amount]} ON 0
 ,NON EMPTY 
    {[TopSalesbyYearAndProd]} ON 1
FROM [Adventure Works];

这似乎可行 - 可能有更优雅的方法,但我还没有找到它:

WITH 
  SET [TopSalesbyYearAndProd] AS 
    Generate
    (
      [Date].[Calendar Year].[Calendar Year].MEMBERS
     ,TopCount
      (
          [Date].[Calendar Year].CurrentMember
        * 
          [Product].[Product].[Product].MEMBERS
       ,4
       ,[Measures].[Internet Sales Amount]
      )
    ) 
  MEMBER [Measures].[TopResellerAmount] AS 
    (
      Generate
      (
        {[Date].[Calendar Year].CurrentMember}
       ,TopCount
        (
            [Date].[Calendar Year].CurrentMember
          * 
            [Product].[Product].[Product].MEMBERS
         ,1
         ,[Measures].[Reseller Sales Amount]
        )
      ).Item(0).Item(1)
     ,[Measures].[Reseller Sales Amount]
    ) 
SELECT 
  {
    [Measures].[Internet Sales Amount]
   ,[Measures].[TopResellerAmount]
  } ON 0
 ,NON EMPTY 
    {[TopSalesbyYearAndProd]} ON 1
FROM [Adventure Works];