2012-04-30 90 views
0

我有幾個角色扮演維度是FK的日期維度。我如何最好地計算從日期維度中的日期與角色扮演維度中的日期相匹配的交集?計算兩個日期匹配的交叉點

在SQL它會是這樣的:

Select DimDate, 
      COUNT(1) 
    From DimDateTable  D 
    join RolePlayingTable R on D.Date = R.Date 
    Group by DimDate 

我想這會工作:

With 
    Member [Measures].[First Date In]  as 
     (
     [Measures].[Account Count], 
     [Sprocket Date].[Date].CurrentMember 
     ) 
    Member [Measures].[First Date Out]  as 
     (
     [Measures].[Account Count], 
     [Widget Date].[Date].CurrentMember 
     ) 


    Select 
      { 
      [Measures].[First Date In], 
      [Measures].[First Date Out] 
      } on 0, 

      Non Empty 
      [Dim Calendar].[Date].[Date] on 1 

    From [Cube-Bert] 

但它只能算作交叉點,而不是在Sproket.Date = Calendar.Date

我也嘗試過這一點,但它是不正確或者:

with 
    Member [Measures].[Count] as 
     Sum(
      Exists(
       {[Sproket Date].[Date].[Date]}, 
       {[Dim Calendar].[Date].[Date]} 
       ) 
      ,[Measures].[Account Count] 
      ) 

    select [Measures].[Count] on 0, 
      Non Empty 
      [Dim Calendar].[Date].members on 1 
    from [Cube-Bert] 
+1

我最終使用的答案是在我的DSV中添加基於日期匹配的0和1標誌列中的計算字段。我試圖使用LinkMember函數,但不成功。我覺得我受騙了,但是在我受到時間限制的情況下,我別無選擇。 –

回答

0

我把日期匹配邏輯放入DSV中,並在事實表中產生一個標誌列,1 = true,0 = false。