2014-01-20 70 views
2

我們已經在這個SO Post添加或進入過濾功能

WITH 
    MEMBER [Measures].[LevelName] AS 
     [Employee].[Employee Department].CurrentMember.Level.Name 
    MEMBER [Measures].[LevelNumber] AS 
     [Employee].[Employee Department].CurrentMember.Level.Ordinal 
    MEMBER [Measures].[MemName] AS 
     [Employee].[Employee Department].CurrentMember.Name 
    SET [Set_TargetEmp] AS 
     { 
     FILTER(
      [Employee Department].AllMembers, 
       (
       InStr(
        1, 
        [Employee].[Employee Department].currentmember.name, 
        "WC4") <> 0 
       ) 
      ) 
     } 
SELECT 
    { 
    [Measures].[MemName], 
    [Measures].[LevelName], 
    [Measures].[LevelNumber] 
    } ON 0, 
    Hierarchize(
     Generate([Set_TargetEmp] as e, 
      Ascendants(e.Current) 
      + 
      Descendants(e.Current, e.Current.Level, SELF_AND_AFTER) 
     ) 
    ) 
    ON 1 
FROM [Adventure Works] 

我想打一個小的變化,但新的成員得到了下面的感謝@FrankPI(魯本H. D'SA)誰是關鍵53,沒有出現在結果集中。爲什麼?

WITH 
    MEMBER [Measures].[LevelName] AS 
     [Employee].[Employee Department].CurrentMember.Level.Name 
    MEMBER [Measures].[LevelNumber] AS 
     [Employee].[Employee Department].CurrentMember.Level.Ordinal 
    MEMBER [Measures].[MemName] AS 
     [Employee].[Employee Department].CurrentMember.Name 
    SET [Set_TargetEmp] AS 
     { 
     FILTER(
      [Employee Department].AllMembers, 
       (
       InStr(
        1, 
        [Employee].[Employee Department].currentmember.name, 
        "David P. Hamilton") <> 0 
       ) 
      or 
      [Employee].[Employee Department].currentmember.member_key = 53 //<<<<<<new bit 
      ) 
     } 
SELECT 
    { 
    [Measures].[MemName], 
    [Measures].[LevelName], 
    [Measures].[LevelNumber] 
    } ON 0, 
    Hierarchize(
     Generate([Set_TargetEmp] as e, 
      Ascendants(e.Current) 
      + 
      Descendants(e.Current, e.Current.Level, SELF_AND_AFTER) 
     ) 
    ) 
    ON 1 
FROM [Adventure Works] 

回答

2

看起來currentmember.member_key = 53沒有返回任何匹配結果。我試過currentmember.Properties("Key0", typed) = 53,並且返回了兩名員工。

請參閱the documentation on the Properties methodthe documentation on intrinsic properties(向下滾動到「非上下文敏感成員屬性」)以獲取詳細信息。

+0

也許我應該使用'IS'而不是'='....將嘗試。這是奇怪的語法弗蘭克'.Properties(「Key0」,鍵入)'你有任何進一步的參考幫助我理解它? – whytheq

+0

我不認爲'''會對這裏有所幫助,因爲它是爲了成員身份,在'IS'的兩邊都有成員。但是你在這裏使用字符串和數字。我沒有嘗試,但也許'=「53」'也可以。我會認爲'member_key'返回一個字符串。 – FrankPl

+0

(+1恥你領域不是t-sql弗蘭克 - 認爲你的代表將是50k,而不是5k然後!....很高興你在這裏,因爲MDX的答案很難找到....我是現在會打綠色的滴答聲:5,000煙花節目開始) – whytheq