加法和减法好,但不是除法

时间:2016-02-11 13:59:18

标签: mdx iccube

使用以下Calc成员:

create calculated member [NbJoursNonAmbuTemp] as 
   sum([Ambu].[Ambu].[Ambu].[Non Ambulatoire], [Nombre de Journées])
create calculated member [NbJoursNonAmbuFinal] as 
    IIF( [Ambu].[Ambu].current is [Ambu].[Ambu].[Ambulatoire], 0, divN([NbJoursNonAmbuTemp], 1 , null)   )
create calculated member [NbSejoursNonAmbuTemp] as 
    sum([Ambu].[Ambu].[Ambu].[Non Ambulatoire], [NbSejours])
create calculated member [NbSejoursNonAmbuFinal] as 
    IIF( [Ambu].[Ambu].current is [Ambu].[Ambu].[Ambulatoire], 0, divN([NbSejoursNonAmbuTemp], 1 , null)   )

以下MDX:

WITH 
  MEMBER toto AS 
    Sum
    (
      CrossJoin
      (
        Descendants
        (
          [Classification GHM].[DA_GP_GA_GHM].CurrentMember
         ,[Classification GHM].[DA_GP_GA_GHM].[GHM]
         ,SELF
        )
       ,Descendants
        (
          [Periode].[Periode].CurrentMember
         ,[Periode].[Periode].[Année-L]
         ,SELF
        )
      )
     ,
        [Measures].[NbSejoursNonAmbuFinal] * [Measures].[dsmFrance]
      / 
        [Measures].[NbJoursNonAmbuFinal]
    ) 
SELECT 
  {
    toto
   ,[Measures].[NbJoursNonAmbuFinal]
  } ON 0
 ,[Classification GHM].[DA_GP_GA_GHM].[All-M] ON 1
FROM [Cube]
WHERE 
    {
      [Etablissement].[Lieu établissement].[Etablissement-L].&[720016724]
    }
  * 
    {[Periode].[Periode].[Année-L].[2014]};

未给出toto ...

的预期值

但是如果不是(分部)

,([Measures].[NbSejoursNonAmbuFinal] * [Measures].[dsmFrance]) / [Measures].[NbJoursNonAmbuFinal]

我尝试(加法)

,([Measures].[NbSejoursNonAmbuFinal] * [Measures].[dsmFrance]) + [Measures].[NbJoursNonAmbuFinal]

或(Substraction)

,([Measures].[NbSejoursNonAmbuFinal] * [Measures].[dsmFrance]) - [Measures].[NbJoursNonAmbuFinal]

一切都正确计算......

我做错了什么?

对于@whytheq建议,我使用以下方式获得了良好的结果:

WITH 
  MEMBER HospidiagWIP AS 
    Sum
    (
      CrossJoin
      (
        Descendants
        (
          [Classification GHM].[DA_GP_GA_GHM].CurrentMember
         ,[Classification GHM].[DA_GP_GA_GHM].[GHM]
         ,SELF
        )
       ,Descendants
        (
          [Periode].[Periode].CurrentMember
         ,[Periode].[Periode].[Année-L]
         ,SELF
        )
      )
     ,
      [Measures].[NbSejoursNonAmbuFinal] * [Measures].[dsmFrance]
    ) 
    MEMBER [Measures].[IPDMS HospidiagTest] as HospidiagWIP / [Measures].[NbJoursNonAmbuFinal]  , format_string='0.000'
SELECT 
  {
   [Measures].[IPDMS HospidiagTest]
   ,[Measures].[IPDMS]
  } ON 0
 ,[Classification GHM].[DA_GP_GA_GHM].[All-M] ON 1
 // ,{[Classification GHM].[DA_GP_GA_GHM].[All-M]} * {[Periode].[Periode].[Année-L].[2013], [Periode].[Periode].[Année-L].[2014]} ON 1

FROM [Cube]
WHERE 
    {
      [Etablissement].[Lieu établissement].[Etablissement-L].&[720016724]
    }
  * 
    {[Periode].[Periode].[Année-L].[2014]}

1 个答案:

答案 0 :(得分:2)

尝试以下操作并检查结果 - 是否有助于分析引擎的作用?

尝试执行解决订单。

WITH 
  MEMBER PREtoto AS
        [Measures].[NbSejoursNonAmbuFinal] * [Measures].[dsmFrance]
      / 
        [Measures].[NbJoursNonAmbuFinal]
     ,SOLVE_ORDER = 1
  MEMBER toto AS 
    Sum
    (
      CrossJoin
      (
        Descendants
        (
          [Classification GHM].[DA_GP_GA_GHM].CurrentMember
         ,[Classification GHM].[DA_GP_GA_GHM].[GHM]
         ,SELF
        )
       ,Descendants
        (
          [Periode].[Periode].CurrentMember
         ,[Periode].[Periode].[Année-L]
         ,SELF
        )
      )
     ,
      PREtoto
    ) 
    ,SOLVE_ORDER = 2   //<<or try the other way by changing to -1
SELECT 
  {
    PREtoto
   ,toto
   ,[Measures].[NbJoursNonAmbuFinal]
  } ON 0
 ,[Classification GHM].[DA_GP_GA_GHM].[All-M] ON 1
FROM [Cube]
WHERE 
    {
      [Etablissement].[Lieu établissement].[Etablissement-L].&[720016724]
    }
  * 
    {[Periode].[Periode].[Année-L].[2014]};