计算两个日期匹配的交叉点

时间:2012-04-30 20:50:37

标签: ssas mdx

我有几个角色扮演维度是日期维度的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 个答案:

答案 0 :(得分:0)

我将日期匹配逻辑放入DSV并在事实表中生成一个标志列,1 = true,0 = false。