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

How to add condition (measure is greater than 0) in an MDX query

我在 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 子句 where [Measures].[ACT LAB HRS]>0 但它 returns 总是出错,如何更正它?

您可以使用 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];