2014-09-01 96 views
0

我被這個問題困住了。我們有一個MDX需要更新以彙總最近六個月的報告,因此MDX會返回最近六個月的彙總數據。MDX過濾器條件集

我不是MDX的專家,有人可以請幫忙,這可以實現嗎?

IDEA:我想過濾最近六個月的報告,但我不明白這是如何在語法上實現的。

MEMBER [TIME].[_TIME1] AS 'Aggregate({ [TIME].&[201401].lag(5):[TIME].&[201401] })' 

實際MDX查詢:

with 

set [reports] as 'Filter(
     [Report].[Report].Members, 
     Int([Measures].[Report Month Id]) = Int(([Measures].[Time Id], [TIME].&[201401])) and 
     Int([Measures].[Report Root Index Id]) = Int(([Measures]. [Index Id], [INDEX_1].[All].&[1])) 
    )' 

    set [Indexes] as 'Descendants([INDEX_1].[All].&[1])' 

    member [Measures].[N] as 'iif(Cstr([Measures].[Index Type Name]) = "Choice Index", ([Measures].[Direct Response Count]), ([Measures].[Direct Case Count]))' 
    member [Measures].[Score] as '([Measures].[Direct Score])' 

    member [Measures].[Item Id]   as 'iif(isEmpty([Measures].[N]), null, [Measures].[Index Id])'  
    member [Measures].[Item Code]  as 'iif(isEmpty([Measures].[N]), null, [Measures].[Index Code])'  
    member [Measures].[Org Id]   as 'iif(isEmpty([Measures].[N]), null, [Measures].[Report Organisation Id])'  


select  
    non empty crossjoin ([reports] , [indexes]) on rows ,      
    { 
     [Measures].[Org Id], [Measures].[Item Id], [Measures].[Item Code], [Measures].[N], [Measures].[Score] 
    } on columns  

from [REPORT_SCORE]  
where 
(
    [ORGANISATION].&[3196] 
) 

回答

0

你問過這樣的事情?:

WITH SET [Last 6 Months] AS 
       { 
        PARALLELPERIOD([Time].[Year - Quarter - Month - Week - Day].[Month], 
            5, 
            StrToMember("[Time].[Year - Quarter - Month - Week - Day].[Day].&[" + Format(Now(), "yyyy-MM-dd") + "T00:00:00]")).Parent.Parent 
        : 
        StrToMember("[Time].[Year - Quarter - Month - Week - Day].[Day].&[" + Format(Now(), "yyyy-MM-dd") + "T00:00:00]").Parent.Parent 
       } 
MEMBER [Time].[Year - Quarter - Month - Week - Day].[AggregatedMonths] AS Aggregate([Last 6 Months]) 

SELECT [Measures].[Your Measure] ON COLUMNS, 
[Time].[Year - Quarter - Month - Week - Day].[AggregatedMonths] ON ROWS 
FROM [Your Cube]