需要得到一个维度的所有成员减去一个成员的总和

时间:2011-06-10 15:23:41

标签: mdx

我正在尝试制作一个MDX查询,可以告诉我在中国以外的国家/地区销售了多少产品。通过以下查询,我只能得到每个国家的瓶装水销售单位,而不是它们的总和。如何修改查询以获得总和?

SELECT NON EMPTY Except(
   {[Location].[All Places].Children}, 
   {[Location].[China]}
) ON COLUMNS,
  {[Product].[All Products].[Bottled Water].Children} ON ROWS
FROM [Places]
WHERE [Measures].[Units Sold]

1 个答案:

答案 0 :(得分:2)

以下应该做你想做的事:

WITH 
  SET [countries] as Except( {[Location].[All Places].Children}, {[Location].[China]} )
  MEMBER [measures].[X] as Sum( [countries] , [Measures].[Units Sold] )

SELECT {[Product].[All Products].[Bottled Water].Children} ON ROWS 
FROM [Places] 
WHERE [measures].[x]