MDX过滤用于度量

时间:2018-05-25 10:40:36

标签: sql mdx

请帮助,需要过滤掉:

  

[措施]。[销售额] + [措施]。[未完成订单] +   [措施]。[销售额]<> 0

以下是我的查询:

SELECT
  NON EMPTY { [Measures].[Ending Quantity],
  [Measures].[Average Unit Cost],
  [Measures].[Cost Amount],
  [Measures].[Sales Amount],
  [Measures].[Invoiced Quantity],
  [Measures].[Outstanding Orders],
  [Measures].[Average Unit Price] } ON COLUMNS,
  NON EMPTY { (
    [Item].[Item].[Item].ALLMEMBERS * [Item].[Last GRN Date].[Last GRN Date].ALLMEMBERS * [Item].[Division].[Division].ALLMEMBERS * [Item].[Last Order Number].[Last Order Number].ALLMEMBERS * [Item].[Vendor Item Number].[Vendor Item Number].ALLMEMBERS * [Item].[Unit Cost].[Unit Cost].ALLMEMBERS * [Item].[Current Retail Price].[Current Retail Price].ALLMEMBERS * [Item].[Vendor Name].[Vendor Name].ALLMEMBERS * [Item].[Last In Date].[Last In Date].ALLMEMBERS * [Item].[Last Markdown Date].[Last Markdown Date].ALLMEMBERS * [Item].[Last Markdown Code].[Last Markdown Code].ALLMEMBERS * [Item].[Buyer].[Buyer].ALLMEMBERS * [Item].[Inventoriable].[Inventoriable].ALLMEMBERS * [Item].[Original Retail Price].[Original Retail Price].ALLMEMBERS
  ) } DIMENSION PROPERTIES MEMBER_CAPTION,
  MEMBER_VALUE,
  MEMBER_UNIQUE_NAME ON ROWS
FROM
  (
    SELECT
      (
        { [Item].[Division].& [1000],
        [Item].[Division].& [2000],
        [Item].[Division].& [3000],
        [Item].[Division].& [4000],
        [Item].[Division].& [5000],
        [Item].[Division].& [6000],
        [Item].[Division].& [7000],
        [Item].[Division].& [8000],
        [Item].[Division].& [9000] }
      ) ON COLUMNS
    FROM
      (
        SELECT
          (
            { [Item].[Buyer].& [SHARAN],
            [Item].[Buyer].& [ALISHA],
            [Item].[Buyer].& [NORMAN],
            [Item].[Buyer].& [MARISA] }
          ) ON COLUMNS
        FROM
          (
            SELECT
              ({ [Item].[Inventoriable].& [Inventoriable] }) ON COLUMNS
            FROM
              [Sales Purchases and Stock]
          )
      )
  ) CELL PROPERTIES VALUE,
  BACK_COLOR,
  FORE_COLOR,
  FORMATTED_VALUE,
  FORMAT_STRING,
  FONT_NAME,
  FONT_SIZE,
  FONT_FLAGS;

1 个答案:

答案 0 :(得分:1)

您应该添加带有过滤器的where子句。类似的东西:

WHERE
   (
    FILTER 
      (
        [Measures].[Sales Amount] + [Measures].[Outstanding Orders] + [Measures].[Sales Amount] <> 0
      )
   );

或者您可以将过滤器添加到以下维度:

SELECT measure1,measure2 ON ROWS
FILTER(
dimension1 * dimension2 * dimension3 

,[Measures].[Sales Amount] + [Measures].[Outstanding Orders] + [Measures].[Sales Amount] <> 0)

ON COLUMNS

或使用HAVING子句,使用如下:

SELECT dimension on 0, HAVING measure<>0 on 1 from ...