2014-02-12 28 views
2

我有兩個維度,分別稱爲[Session Length][Date],以及我的Cube中稱爲[Count - Logins]的度量。 [Session Length]維包含一個名爲[Session Length]的屬性,其成員是從0240的整數。創建自定義的MDX命名集合

我喜歡寫MDX查詢該會集結[Count - Logins][Session Length]尺寸定製的子集(即我想創建一個基於[Session Length]尺寸定製的集並聚集在這個組自定義的單個成員的數量)。下面是該查詢我來了這麼遠,但不幸的是我不知道如何前進:

WITH SET [Description] AS { 
     [SessionLength].[Session Length].&[0], //Glimpse 
     [SessionLength].[Session Length].&[1]:[SessionLength].[Session Length].&[5], //Short 
     [SessionLength].[Session Length].&[6]:[SessionLength].[Session Length].&[30], //Medium 
     [SessionLength].[Session Length].&[31]:[SessionLength].[Session Length].&[90], //Long 
     [SessionLength].[Session Length].&[90]:[SessionLength].[Session Length].&[240]} //Extended 
    MEMBER [SessionLength].[Session Length].SessionDescription AS 
      Aggregate([Description]) 
    SELECT 
    { [Measures].[Count - Logins] } 
    ON COLUMNS, 
    NONEMPTY({[SessionLength].[Session Length].SessionDescription} * {[Date].[Date].[Date]}) ON ROWS 
FROM MyCube 

具有下列樣品結果集:

Session Length | Date | Count - Logins 
    ------------------------------------------------- 
    SessionDescription | 2014-02-01 | 22 
    SessionDescription | 2014-02-01 | 17 

正如你所看到的計數被整個集合而不是每個成員單獨聚合。這裏是我希望產生的結果:

Session Length | Date | Count - Logins 
    ------------------------------------------------- 
    Glimpse   | 2014-02-01 | 3 
    Short    | 2014-02-01 | 4 
    Medium    | 2014-02-01 | 9 
    Long    | 2014-02-01 | 5 
    Extended   | 2014-02-01 | 1 
    Glimpse   | 2014-02-02 | 2 
    Short    | 2014-02-02 | 5 
    Medium    | 2014-02-02 | 7 
    Long    | 2014-02-02 | 2 
    Extended   | 2014-02-02 | 1 

任何幫助,將不勝感激。我知道這可以通過修改DSV來實現,但我不想改變Cube的結構。

回答

4

如果您想在行上看到單獨的條目,則必須創建單獨的SessionDescription成員。 G。像這樣:

WITH 
    MEMBER [SessionLength].[Session Length].Glimpse AS 
      Aggregate([SessionLength].[Session Length].&[0]) 
    MEMBER [SessionLength].[Session Length].Short AS 
      Aggregate([SessionLength].[Session Length].&[1]:[SessionLength].[Session Length].&[5]) 
    MEMBER [SessionLength].[Session Length].Medium AS 
      Aggregate([SessionLength].[Session Length].&[6]:[SessionLength].[Session Length].&[30]) 
    MEMBER [SessionLength].[Session Length].Long AS 
      Aggregate([SessionLength].[Session Length].&[31]:[SessionLength].[Session Length].&[90]) 
    MEMBER [SessionLength].[Session Length].Extended AS 
      Aggregate([SessionLength].[Session Length].&[90]:[SessionLength].[Session Length].&[240]) 
    SELECT 
    { [Measures].[Count - Logins] } 
    ON COLUMNS, 
    NONEMPTY({ 
      [SessionLength].[Session Length].Glimpse, 
      [SessionLength].[Session Length].Short, 
      [SessionLength].[Session Length].Medium, 
      [SessionLength].[Session Length].Long, 
      [SessionLength].[Session Length].Extended 
      } 
      * {[Date].[Date].[Date]}) 
    ON ROWS 
FROM MyCube 

順便說一句,我離開了90成員在這兩個,LongExtended因爲它是在你的原始查詢。如果你不想重複這些,你應該從一箇中刪除它們。