mdx topcount结果不如预期

时间:2015-03-22 19:19:57

标签: ssas mdx olap

当我运行下面的查询时,我只返回2条记录。如果我放弃TOPCOUNT,我会获得508条记录。

为什么不给我508条记录中的前5名?我错过了什么?

with 
MEMBER Measures.[EmailCount] as IIF(ISEMPTY([Measures].[Tran Count]), 0 ,[Measures].[Tran Count])  
MEMBER Measures.[IncomePerEmail] as 
    [Measures].[Amount]/ IIF(Measures.[EmailCount] = 0, 1 , Measures.[EmailCount] )
MEMBER Measures.[Income Range] as
 CASE  
      WHEN Sum(EXISTING [Dim IFA Details].[Parent Key].[Adviser Group].Members,
            Measures.[Amount] ) <= 10000 THEN  '0-10000'
      WHEN Sum(EXISTING [Dim IFA Details].[Parent Key].[Adviser Group].Members,
            Measures.[Amount] ) <= 50000 THEN  '10001-50000'
      WHEN Sum(EXISTING [Dim IFA Details].[Parent Key].[Adviser Group].Members,
            Measures.[Amount] ) <= 100000 THEN  '50001-100000'
      WHEN Sum(EXISTING [Dim IFA Details].[Parent Key].[Adviser Group].Members,
            Measures.[Amount] ) <= 200000 THEN  '100001-200000'
      else '> 200000'
      end

SELECT   {  [Measures].[Amount] , Measures.[EmailCount], measures.[Income Range], Measures.[IncomePerEmail] } 
 ON COLUMNS, 
 TOPCOUNT( 
 NONEMPTY([Dim IFA Details].[Parent Key].[Adviser Group].Members, Measures.Amount)
, 5
, Measures.[IncomePerEmail] 
)
having Measures.[Income Range] = '10001-50000' 
on rows
FROM [Income and Emails Cube] 
where [Dim Date].[Fiscal Year].&[FY 13/14]

1 个答案:

答案 0 :(得分:1)

你有一个HAVING子句基本上过滤了这个集合(5个记录)。

TOPCOUNT为您提供了5个成员,但在进行过滤时,只有两个成员符合条件Measures.[Income Range] = '10001-50000'

如果您想验证这一点,请根据Measures.[IncomePerEmail]对查询进行排序,并查看&#34;前5条记录&#34;收入范围为&#39; 10001-50000&#39;