如何在MDX查询中添加条件(度量大于0)

时间:2015-04-02 13:18:28

标签: mdx

我在MDX

中有以下查询
With

  member [Week Count] as 
     ( 
       ([WORK ].[Complying Flag].&[COMPLYING], [Measures].[No of Work ])
/([WORK ].[Complying Flag].[(All)].[All], [Measures].[No of Work ])) *100
select  
  {[Week Count]} on columns,
  {[CLOSED DATE].[Week End Date].members} on rows
FROM [test ]

我需要添加条件where [Measures].[ACT LAB HRS]>0 但它总是返回错误,如何纠正呢?

1 个答案:

答案 0 :(得分:4)

你可以使用Filter,但我们需要一个集合来过滤这样的东西:

WITH
  MEMBER [Week Count] as 
     ( 
       ([WORK ].[Complying Flag].&[COMPLYING], [Measures].[No of Work ])
/([WORK ].[Complying Flag].[(All)].[All], [Measures].[No of Work ])
     ) *100
SELECT  
  {[Week Count]} on columns,
  {[CLOSED DATE].[Week End Date].members} on rows
FROM [test]
WHERE
   (
    FILTER 
      (
        [SomeDimension].[SomeHierarchy].members,
        [Measures].[ACT LAB HRS]>0
      )
   );

另一种方法是包含HAVING子句:

WITH
  MEMBER [Measures].[Week Count] as 
     ( 
       ([WORK ].[Complying Flag].&[COMPLYING], [Measures].[No of Work ])
/([WORK ].[Complying Flag].[(All)].[All], [Measures].[No of Work ])
     ) *100
SELECT  
  {
   [Measures].[Week Count],
   [Measures].[ACT LAB HRS]
  } ON 0,
  {[CLOSED DATE].[Week End Date].members} 
  HAVING [Measures].[ACT LAB HRS]>0
  ON 1
FROM [test];