MDX 在总计算中排除过滤器

MDX exclude filter in total calculation

下面的查询将为 Cycling Cap 产品提供 return 结果,请忽略实际计算,我只是以此为例。我感兴趣的是,我得到的结果基于使用 [Product].[Model Name].&[Cycling Cap] 的数据过滤,见下文。

WITH 
  MEMBER [Measures].[Unit Costing] AS 
  (
  ([Measures].[Total Product Cost] / [Measures].[Unit Price])*    [Measures].[Internet Sales Count] 
    ), format_string = '#,###,###,##0' 

SELECT NON EMPTY { 
  [Measures].[Sales Amount]
, [Measures].[Total Product Cost]
, [Measures].[Unit Price]
, [Measures].[Internet Sales Count] 
, [Measures].[Unit Costing]
} ON COLUMNS, NON EMPTY 
{ 
 {
[Order Date].[Calendar].[Calendar Year].&[2008] * 
[Order Date].[Calendar Month].[Calendar Month] *
[Product].[Model Name].&[Cycling Cap]} -- if this is removed second set of results returned
} DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS 
FROM [Adventure Works Cube]

我返回的是

Sales Amount    Total Product Cost  Unit Price  Internet Sales Count    Unit Costing
2008    August      Cycling Cap 2876.8   2215.136   2876.8  320      246
2008    February    Cycling Cap 5915.42  4554.8734  5915.42 658      507
2008    July        Cycling Cap 2400.33  1848.2541  2400.33 267      206
2008    March       Cycling Cap 5483.9   4222.603   5483.9  610      470

现在,如果我取出 [Product].[Model Name].&[Cycling Cap],结果是

Sales Amount    Total Product Cost  Unit Price  Internet Sales Count    Unit Costing
2008    August      4113748.61980021    2419644.0697        4113748.61980021    8596    5,056
2008    February    8388478.68060071    4930341.31220008    8388478.68060071    17236   10,130
2008    July        4154919.58680019    2445288.84530001    4154919.58680019    8550    5,032
2008    March       8358856.30390072    4919934.72500009    8358856.30390072    17067   10,045

那么,是否可以使用 8 月的单位成本 return 未过滤值 5,056,而不是我目前得到的 246。

如果您在计算中将每个度量与 ALL 成员相加,那么它应该强制它反对 ALL 而不是循环上限:

WITH 
  MEMBER [Measures].[Unit Costing] AS 
        (
          [Measures].[Total Product Cost]
         ,[Product].[Model Name].[All]
        )
      / 
        (
          [Measures].[Unit Price]
         ,[Product].[Model Name].[All]
        )
    * 
      (
        [Measures].[Internet Sales Count]
       ,[Product].[Model Name].[All]
      ) 
   ,format_string = '#,###,###,##0' 
SELECT 
  NON EMPTY 
    {
      [Measures].[Sales Amount]
     ,[Measures].[Total Product Cost]
     ,[Measures].[Unit Price]
     ,[Measures].[Internet Sales Count]
     ,[Measures].[Unit Costing]
    } ON COLUMNS
 ,NON EMPTY 
    -- if this is removed second set of results returned
    {
        [Order Date].[Calendar].[Calendar Year].&[2008]*
        [Order Date].[Calendar Month].[Calendar Month]*
        [Product].[Model Name].&[Cycling Cap]
    } ON ROWS
FROM [Adventure Works];