2016-07-12 5 views
0

私が適用したフィルタを使用して、次のデータプルに基づいて最初の日付の行を取得しようとしています。以下のクエリには「親の事件ID」キーの重複があります。「N」などで始まる「変更されたID」の下のフィルタリングされたパラメータ内の最も早い日付です。私はかなりの数の括弧を削除することにより、簡素化することによって開始するMDX Eariestセット内の日付

David 123456 1/5/2016 10:03:29 AM 1 
David 111111 2/9/2016 10:05:31 AM 1 
Samuel 123456 2/9/2016 10:07:01 AM 1 
Samuel 111111 1/6/2016 12:03:29 AM 1 

答えて

0

ステップ・バイ・ステップ(願わくば!)

1.Initially:

SELECT 
NON EMPTY {[Measures].[Count of Assignee Reassignments]} ON COLUMNS, 
NON EMPTY 
    { 
    (
     [Related Assignee History].[Modified By Id].[Modified By Id].ALLMEMBERS 
    *[Related Assignee History].[Parent Incident Id].[Parent Incident Id].ALLMEMBERS 
    *[Related Assignee History].[Start Date Time].[Start Date Time].AllMembers 
    ) 
    } 
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS 

FROM(
    SELECT 
     (
     Filter(
      [Related Assignee History].[Modified By Id].Children 
      ,Left([Related Assignee History].[Modified By Id].CurrentMember.Name,1)="n" 
     ) 
     ) ON COLUMNS 
    FROM(
     SELECT 
      (
      { [Incident].[Owner Group].&[Directors Group]}) ON COLUMNS 
     FROM(
      SELECT 
       (
       {[Incident].[Reported Source].&[Self Service]}) ON COLUMNS 
      From(
       Select 
        (
         {[Related Assignee History].[Start Date Time].ITEM(0)}) on columns 
       FROM(
        SELECT({[Date Reported].[Year].&[2016] }) ON COLUMNS 
        FROM [Incident] 
        ) 
       ) 
      ) 
     ) 
    ); 

結果は次のようになり

SELECT 
NON EMPTY 
    [Measures].[Count of Assignee Reassignments] ON 0, 
NON EMPTY 
    [Related Assignee History].[Modified By Id].[Modified By Id].ALLMEMBERS 
    *[Related Assignee History].[Parent Incident Id].[Parent Incident Id].ALLMEMBERS 
    *[Related Assignee History].[Start Date Time].[Start Date Time].ALLMEMBERS 
FROM(
    SELECT 
     FILTER(
      [Related Assignee History].[Modified By Id].Children 
      ,Left([Related Assignee History].[Modified By Id].CurrentMember.Name,1)="n" 
     ) ON 0 
    FROM(
     SELECT 
      [Incident].[Owner Group].&[Directors Group] ON 0 
     FROM(
      SELECT 
       [Incident].[Reported Source].&[Self Service] ON 0 
      FROM(
       SELECT 
        [Related Assignee History].[Start Date Time].ITEM(0) ON 0 
       FROM 
        (
        SELECT [Date Reported].[Year].&[2016] ON 0 
        FROM [Incident] 
        ) 
       ) 
      ) 
     ) 
    ); 

2. [Date Reported].[Year].&[2016]に興味がある場合は、狂ったネストされたサブセレクトから移動してください -

SELECT 
NON EMPTY 
    [Measures].[Count of Assignee Reassignments] ON 0, 
NON EMPTY 
    [Related Assignee History].[Modified By Id].[Modified By Id].ALLMEMBERS 
    *[Related Assignee History].[Parent Incident Id].[Parent Incident Id].ALLMEMBERS 
    *[Related Assignee History].[Start Date Time].[Start Date Time].ALLMEMBERS 
FROM 
    (
    SELECT 
     FILTER(
      [Related Assignee History].[Modified By Id].Children 
      ,Left([Related Assignee History].[Modified By Id].CurrentMember.Name,1)="n" 
     ) ON 0 
    FROM 
     (
     SELECT 
      [Related Assignee History].[Start Date Time].ITEM(0) ON 0 
     FROM [Incident] 
     ) 
    ) 
WHERE 
([Date Reported].[Year].&[2016] 
,[Incident].[Owner Group].&[Directors Group] 
,[Incident].[Reported Source].&[Self Service]); 

3.NowはWITH句の中にフィルターを動かすと、そのようなナサニエルなどNで始まる名前を検索しMember_Captionプロパティを使用することができます: - WHERE句にも同様にこのWHERE句にインシデントのメンバーを移動することができますこの[Related Assignee History].[Start Date Time].ITEM(0)は私が時間ビーイングのためにそれを削除しますので、それぞれの人のための分の日付を見つけるためにあなたの試みであることを推測

WITH 
    SET [N_names] AS 
    FILTER(
      [Related Assignee History].[Modified By Id].[Modified By Id].MEMBERS 
      ,Left([Related Assignee History].[Modified By Id].CurrentMember.MEMBER_CAPTION,1) = 'N' 
    ) 
SELECT 
NON EMPTY 
    [Measures].[Count of Assignee Reassignments] ON 0, 
NON EMPTY 
    [N_names] 
    *[Related Assignee History].[Parent Incident Id].[Parent Incident Id].ALLMEMBERS 
    *[Related Assignee History].[Start Date Time].[Start Date Time].ALLMEMBERS 
FROM 
    (
    SELECT 
     [Related Assignee History].[Start Date Time].ITEM(0) ON 0 
    FROM [Incident] 
) 
WHERE 
([Date Reported].[Year].&[2016] 
,[Incident].[Owner Group].&[Directors Group] 
,[Incident].[Reported Source].&[Self Service]); 

4.I'm:私たちは、その後SELECT節で設定した名前のを使用します。

WITH 
    SET [N_names] AS 
    FILTER(
      [Related Assignee History].[Modified By Id].[Modified By Id].MEMBERS 
      ,Left([Related Assignee History].[Modified By Id].CurrentMember.MEMBER_CAPTION,1) = 'N' 
    ) 
SELECT 
NON EMPTY 
    [Measures].[Count of Assignee Reassignments] ON 0, 
NON EMPTY 
    [N_names] 
    *[Related Assignee History].[Parent Incident Id].[Parent Incident Id].ALLMEMBERS 
    *[Related Assignee History].[Start Date Time].[Start Date Time].ALLMEMBERS 
FROM [Incident] 
WHERE 
([Date Reported].[Year].&[2016] 
,[Incident].[Owner Group].&[Directors Group] 
,[Incident].[Reported Source].&[Self Service]); 

それは少し複雑になります5.Now:

WITH 
    SET [N_names] AS 
    FILTER(
      [Related Assignee History].[Modified By Id].[Modified By Id].MEMBERS 
      ,Left([Related Assignee History].[Modified By Id].CurrentMember.MEMBER_CAPTION,1) = 'N' 
    ) 
    SET [N_names_plusDates] AS 
    GENERATE(
     [N_names] AS N 
     , N.CURRENTMEMBER 
      * TAIL(
       NONEMPTY(
       [Related Assignee History].[Start Date Time].[Start Date Time].MEMBERS 
       ,N.CURRENTMEMBER 
       ) 
      ) 
    ) 
SELECT 
NON EMPTY 
    [Measures].[Count of Assignee Reassignments] ON 0, 
NON EMPTY 
    [N_names_plusDates] 
    *[Related Assignee History].[Parent Incident Id].[Parent Incident Id].ALLMEMBERS 
FROM [Incident] 
WHERE 
([Date Reported].[Year].&[2016] 
,[Incident].[Owner Group].&[Directors Group] 
,[Incident].[Reported Source].&[Self Service]); 
関連する問題