在mdx中,根据维度值,在计算中使用一个或另一个度量

时间:2017-01-30 14:37:24

标签: mdx iccube

我想根据尺寸值计算某些东西:我试过

WITH 
  CALCULATED MEMBER [Measures].[Switch] AS 
    IIF
    (
      [Ambu].[Ambu].CurrentMember IS [Ambu].[Ambu].[Non Ambulatoire]
     ,[Measures].[Nombre de Journées]
     ,(
        [Measures].[NbSejours]
       ,[Ambu].[Ambu].[Ambulatoire]
      )
    ) 
  MEMBER result AS 
    [Measures].[RecettesT2a] / [Measures].[Switch] 
SELECT 
  {
    [Measures].[RecettesT2a]
   ,[Measures].[Switch]
   ,result
   ,[Measures].[NbSejours]
   ,[Measures].[Nombre de Journées]
  } ON 0
 ,[Ambu].[Ambu] ON 1
 --[Classification GHM].[Recours] on 1
FROM [Cube];

事实上,如果Ambu是Ambu,我想用NbSejours划分RecettesT2a,如果Ambu是非Ambu,我想将[ReceutesT2a]划分为[NombredeJournées] ......

当Ambu用于Axis 1时,此结果为OK,但如果我想将另一个维度用作Axis 1(例如[Classification GHM]。[Recours]),则它不起作用... [Measures]。[切换]未正确计算...

1 个答案:

答案 0 :(得分:1)

Ambu脱离背景时,我们不知道您需要什么。

因此,根据您的需要,您有两种选择:

WITH 
  CALCULATED MEMBER [Measures].[Switch] AS 
    IIF
    (
        [Ambu].[Ambu].CurrentMember IS [Ambu].[Ambu].[Non Ambulatoire]
      OR 
        isAll([Ambu].[Ambu].CurrentMember)
     ,[Measures].[Nombre de Journées]
     ,(
        [Measures].[NbSejours]
       ,[Ambu].[Ambu].[Ambulatoire]
      )
    ) 
...
...

或者这个:

WITH 
  CALCULATED MEMBER [Measures].[Switch] AS 
    IIF
    (
        [Ambu].[Ambu].CurrentMember IS [Ambu].[Ambu].[Non Ambulatoire]
      OR 
        NOT isAll([Ambu].[Ambu].CurrentMember)
     ,[Measures].[Nombre de Journées]
     ,(
        [Measures].[NbSejours]
       ,[Ambu].[Ambu].[Ambulatoire]
      )
    ) 
...
...