在mdx中一起使用extract和count函数

时间:2017-02-26 07:18:44

标签: count extract mdx

我有一个Mdx查询,我想一起使用Extract和count函数,但它不会返回任何内容。有人可以帮帮我吗? (我想数人有tradcnt> 0,我使用提取因为如果我不使用它,如果一个人在提及日期有多个交易,那个人被计算多次但我想被计算一次)

WITH
 SET [people in first date] AS   
  Filter  
      (  
       {[VW Dim Customer Broker Branch].[Customer BK].[Customer BK]*[Vw Dim Date].[Shamsi Date].&[1388/06/01]:[Vw Dim Date].[Shamsi Date].&[1388/06/02]},
       [Measures].[Trade Cnt]>0
      ) 

SET [ExtractPeopleFromFirstDate] as
    Extract(
        [people in first date],
        [VW Dim Customer Broker Branch].[Customer BK]
    )

member [measures].[numberOfPeopleInFirstDate] AS
    Count([ExtractPeopleFromFirstDate])
select

  {} on 0,
   [ExtractPeopleFromFirstDate] on 1 
  from [DVPL]

1 个答案:

答案 0 :(得分:0)

可能不需要Extract - NonEmpty有帮助吗?

WITH
 MEMBER [Vw Dim Date].[Shamsi Date].[All].[DtRange] AS
   AGGREGATE(
    [Vw Dim Date].[Shamsi Date].&[1388/06/01]
   :[Vw Dim Date].[Shamsi Date].&[1388/06/02]
   )
 SET [people in first date] AS   
  NONEMPTY  
      (  
        [VW Dim Customer Broker Branch].[Customer BK].[Customer BK]
       ,(
          [Vw Dim Date].[Shamsi Date].[All].[DtRange]
         ,[Measures].[Trade Cnt]
        )
      ) 
 MEMBER [Measures].[numberOfPeopleInFirstDate] AS
    [people in first date].COUNT
SELECT
   {} on 0,
   [Measures].[numberOfPeopleInFirstDate]  on 1 
FROM [DVPL];

Greg问题的答案很重要 - 好像你的立方体中有0,而不是空格,那么上面的内容是错误的:FILTER可能是一个选项。