仅在成员相等的情况下MDX交叉连接

时间:2014-05-27 10:19:52

标签: ssas mdx

是否可以交叉加入并仅在两个成员相等的情况下返回?例如,针对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查询获得以下结果?

1 个答案:

答案 0 :(得分: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]