【问题标题】:MDX crossjoin only where members are equal仅当成员相等时才进行 MDX 交叉连接
【发布时间】:2014-06-02 04:18:43
【问题描述】:

是否可以交叉加入并仅在两个成员相等的情况下返回?例如以下针对 SSAS 2012 中的 Adventure Works 的查询

select [Measures].[Reseller Sales Amount] on 0
,topcount(([Ship Date].[Date].Children,[Delivery Date].[Date].Children),5) on 1
from [Adventure Works]

将返回以下值

                     Reseller Sales Amount
January 1, 2005 January 1, 2005 (null)
January 1, 2005 January 2, 2005 (null)
January 1, 2005 January 3, 2005 (null)
January 1, 2005 January 4, 2005 (null)
January 1, 2005 January 5, 2005 (null)

我想要的结果如下

                     Reseller Sales Amount
January 1, 2005 January 1, 2005 (null)
January 2, 2005 January 2, 2005 (null)
January 3, 2005 January 3, 2005 (null)
January 4, 2005 January 4, 2005 (null)
January 5, 2005 January 5, 2005 (null)

无论是否使用交叉连接,我都可以使用 MDX 查询获得如下结果吗?

【问题讨论】:

    标签: ssas mdx


    【解决方案1】:

    这应该适合你。基本上我创建了一个布尔样式的计算成员,然后将该成员包含在 TOPCOUNT 函数中。

    希望对你有帮助。

    WITH MEMBER [Measures].[MatchingDates] AS
    IIF([Ship Date].[Date].MEMBERVALUE = [Delivery Date].[Date].MEMBERVALUE,1,0)
    SELECT
    [Measures].[Reseller Sales Amount] ON 0
    ,   TOPCOUNT({[Ship Date].[Date].[Date].MEMBERS * [Delivery Date].[Date].[Date].MEMBERS},5,[Measures].[MatchingDates]) ON 1
    FROM
    [Adventure Works]
    

    【讨论】:

    • NULL 而不是 0 更好,因为 IIF 的第二个参数
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-04
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多