1

使用此代码,以下代码,产生的排名在 1 和 50 以及 204 和 400 之间完美运行,但在 50 时,当排名指标从负数变为正数时,它会跳过到 204。MDX 创建一个有序集,然后按该集排名。创建排名的计算成员称为 [measures]。[Level5_Rank] (屏蔽的)数据如下所示,请注意排名在排名指标从负数变为正数的精确时刻跳过。

或者它是否可以在查询上下文之外对其他成员进行排名?

Fall joe -1.80E-02 205 Fall john -1.38E-02 204(此处跳过排名!!!) Fall bob 9.12E-03 51 Fall billy 6.13E-02 50

with



 member [Measures].[CYTD Cancel Rate] as
 iif([Measures].[FC Actual PC] + [FC Cancelations PC] = 0, null,
 ( [FC Cancelations PC]/([Measures].[FC Actual PC] + [FC Cancelations PC]) ) )
 , FORMAT_STRING = 'Percent'

 member [measures].[CYTD Cancel Rate vs Goal] as
 IIF(KPIGoal("FC Cancels")=null,null,([Measures].[FC Cancel Rate GL] - [measures].[CYTD Cancel Rate]) * 100)



 set [OrderedLevel5Members] as [Performance Rep Team Org].[Reporting Org Hrchy].[Level5].members 

**member [measures].[Level5_Rank] as IIF(KPIGoal("FC Cancels")=null,null,rank([Performance Rep Team Org].[Reporting Org Hrchy].CurrentMember,OrderedLevel5Members,[Measures].[CYTD Cancel Rate vs Goal]) )**


 member [measures].[Level5] as 
 IIf([Performance Rep Team Org].[Reporting Org Hrchy].CurrentMember.level.ordinal > 4
    ,ancestor([Performance Rep Team Org].[Reporting Org Hrchy].CurrentMember,[Performance Rep Team Org].[Reporting Org Hrchy].[Level5]).member_caption
    ,null
    ) 




 SELECT 
    {
      [measures].[Level5]


        ,[measures].[CYTD Cancel Rate vs Goal]
        ,[measures].[Level5_Rank]

   } ON COLUMNS
 ,NON EMPTY 
    nonempty({
    [Season].[Season].[Season].AllMEMBERS *
        [Performance Rep Team Org].[Reporting Org Hrchy].ALLMEMBERS


    }
        ,{[Measures].[FC Actual PC]}     
    ) 

    DIMENSION PROPERTIES 
    MEMBER_CAPTION
   ,MEMBER_UNIQUE_NAME
   ON ROWS 
FROM 
(SELECT
(
{
    [Performance Rep Team Org].[Reporting Org Hrchy].allmembers

}
)ON COLUMNS
  FROM [Book Fairs Sales]
  )

WHERE
( 
{[Fiscal Year].[Fiscal Year].&[124]
},
{[As Of Time].[Fiscl Hrchy].[Date].&[2012-05-31T00:00:00]
} 
, 
{
[Sales Org Hier Time].[Fiscl Hrchy].[Date].&[2012-05-31T00:00:00]} 
)
4

1 回答 1

1

我需要在排名前在集合中使用非空

WITH 
  MEMBER [Measures].[CYTD Cancel Rate] AS 
    IIF
    (
      [Measures].[FC Actual PC] + [FC Cancelations PC] = 0
     ,null
     ,
      [FC Cancelations PC] / ([Measures].[FC Actual PC] + [FC Cancelations PC])
    ) 
   ,FORMAT_STRING = 'Percent'
  MEMBER [measures].[CYTD Cancel Rate vs Goal] AS 
    IIF
    (
        KPIGoal("FC Cancels")
      = NULL
     ,null
     ,
      ([Measures].[FC Cancel Rate GL] - [measures].[CYTD Cancel Rate]) * 100
    ) 
  SET [OrderedLevel5Members] AS 
    NonEmpty
    ([Performance Rep Team Org].[Reporting Org Hrchy].[Level5].MEMBERS 
    ,[Measures].[CYTD Cancel Rate vs Goal])

  MEMBER [measures].[Level5_Rank] AS 
    IIF
    (
        KPIGoal("FC Cancels")
      = NULL
     ,null
     ,Rank
      (
        [Performance Rep Team Org].[Reporting Org Hrchy].CurrentMember
       ,OrderedLevel5Members
       ,[Measures].[CYTD Cancel Rate vs Goal]
      )
    ) 

SELECT 
  {
    [measures].[CYTD Cancel Rate vs Goal]
   ,[measures].[Level5_Rank]
  } ON COLUMNS
,
--NON EMPTY 

    NonEmpty
    (
      {

          [Performance Rep Team Org].[Reporting Org Hrchy].ALLMEMBERS
      }
     ,{[Measures].[FC Actual PC]}
    )

   ON ROWS
FROM 
(
  SELECT 
    {
      [Performance Rep Team Org].[Reporting Org Hrchy].ALLMEMBERS
    } ON COLUMNS
  FROM [Book Fairs Sales]
)
WHERE 
  (
  [Season].[Season].&[Fall]
    ,[Fiscal Year].[Fiscal Year].&[124]
   ,[As Of Time].[Fiscl Hrchy].[Date].&[2012-05-31T00:00:00]
   ,
      [Sales Org Hier Time].[Fiscl Hrchy].[Date].&[2012-05-31T00:00:00]

  );

http://social.msdn.microsoft.com/Forums/eu/sqlanalysisservices/thread/1264dbe8-bc6a-46d5-89b1-6d8825929ba0

于 2012-07-19T17:32:57.213 回答