MDX - 过滤多个维度

发布于 2024-07-20 09:12:40 字数 1020 浏览 6 评论 0原文

我正在尝试形成一个 MDX 查询,以便它仅返回度量满足特定条件的两个维度的组合。 我认为使用 FILTER 函数这会非常简单,即

SELECT
    NON EMPTY FILTER({[Program].[ByRegion].[Program] * [Performance Metric].[Metric].CHILDREN }, [Measures].[Point Percentage] < .95) ON ROWS,
    NON EMPTY ( HIERARCHIZE([Calendar Period].[Y-Q-M].[Month of Quarter].&[3]&[1]&[2009]) , [Measures].[Point Percentage] )ON COLUMNS
FROM [QEP Revenue]

但是,在运行查询后,很容易发现我有一个错误,因为第一个结果的点百分比为 1.5172,显然超过 0.95 。

如果我完全删除过滤器:

SELECT
    --NON EMPTY FILTER({[Program].[ByRegion].[Program] * [Performance Metric].[Metric].CHILDREN }, [Measures].[Point Percentage] < .95) ON ROWS,
    NON EMPTY ({[Program].[ByRegion].[Program] * [Performance Metric].[Metric].CHILDREN }) ON ROWS,
    NON EMPTY ( HIERARCHIZE([Calendar Period].[Y-Q-M].[Month of Quarter].&[3]&[1]&[2009]) , [Measures].[Point Percentage] )ON COLUMNS
FROM [QEP Revenue]

我会得到类似的结果集,其中包括高于 0.95 的值。 我是否完全错过了过滤器的要点,或者尝试一次过滤两个维度是否存在问题?

I'm trying to form an MDX query such that it returns only the combinations of two dimensions where a measure meets a certain criteria. I thought this would be pretty straight forward using the FILTER function, i.e.

SELECT
    NON EMPTY FILTER({[Program].[ByRegion].[Program] * [Performance Metric].[Metric].CHILDREN }, [Measures].[Point Percentage] < .95) ON ROWS,
    NON EMPTY ( HIERARCHIZE([Calendar Period].[Y-Q-M].[Month of Quarter].&[3]&[1]&[2009]) , [Measures].[Point Percentage] )ON COLUMNS
FROM [QEP Revenue]

However, after running the query, it is pretty easy to see that I have a mistake because the very first result has a Point Percentage of 1.5172 which is obviously more than .95.

If I completely remove the filter:

SELECT
    --NON EMPTY FILTER({[Program].[ByRegion].[Program] * [Performance Metric].[Metric].CHILDREN }, [Measures].[Point Percentage] < .95) ON ROWS,
    NON EMPTY ({[Program].[ByRegion].[Program] * [Performance Metric].[Metric].CHILDREN }) ON ROWS,
    NON EMPTY ( HIERARCHIZE([Calendar Period].[Y-Q-M].[Month of Quarter].&[3]&[1]&[2009]) , [Measures].[Point Percentage] )ON COLUMNS
FROM [QEP Revenue]

I get a similar result set including values above .95. Am I completely missing the point of a filter, or is there an issue with attempting to filter two dimensions at once?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

記柔刀 2024-07-27 09:12:40

我没有您的数据源,但此 MDX 适用于 AS2000 示例多维数据集 Foodmart(销售多维数据集)。

SELECT 
  NON EMPTY 
    {{[Time].[Quarter].MEMBERS}} ON COLUMNS
 ,NON EMPTY 
    Filter
    (
      CrossJoin
      (
        {[Customers].[State Province].&[CA]}
       ,[Promotions].[All Promotions].Children
      )
     ,
        (
          [Customers].[State Province].&[CA]
         ,[Time].&[1997].&[Q1]
         ,[Measures].[Unit Sales]
        )
      > 300
    ) ON ROWS
FROM [Sales]
WHERE 
  [Measures].[Unit Sales];

I don't have your datasource, but this MDX works against the AS2000 sample cube, Foodmart (Sales cube).

SELECT 
  NON EMPTY 
    {{[Time].[Quarter].MEMBERS}} ON COLUMNS
 ,NON EMPTY 
    Filter
    (
      CrossJoin
      (
        {[Customers].[State Province].&[CA]}
       ,[Promotions].[All Promotions].Children
      )
     ,
        (
          [Customers].[State Province].&[CA]
         ,[Time].&[1997].&[Q1]
         ,[Measures].[Unit Sales]
        )
      > 300
    ) ON ROWS
FROM [Sales]
WHERE 
  [Measures].[Unit Sales];
樱花坊 2024-07-27 09:12:40

我把它破解了。

过滤器已正确应用于计划和绩效指标维度。 问题在于过滤器是与日历周期维度分开应用的。 因此允许显示 1.5172 的积分百分比,因为另一个月份中存在满足过滤器要求的积分百分比。

我能够重写该查询以获得所需的结果:

SELECT 
  NON EMPTY 
    Filter
    (
      {
          [Program].[ByRegion].[Program]*
          [Performance Metric].[Metric].Children*
          [Calendar Period].[Y-Q-M].[Month of Quarter].&[3]&[1]&[2009]
      }
     ,
      [Measures].[Point Percentage] < 0.95
    ) ON ROWS
 ,NON EMPTY 
    [Measures].[Point Percentage] ON COLUMNS
FROM [QEP Revenue];

幸运的是,该查询正在报告服务中使用,因此将日历周期移动到 ROWS 中是合适的。 但是,如果我想将日历周期保留在列中,我不知道如何解决这个问题,因为两个轴不能使用相同的维度。

I got it cracked.

The filter was being applied correctly to the Program and Performance Metric dimensions. The issue was that the filter was applied separately from the Calendar Period dimension. So the Point Percentage of 1.5172 that showed up was allowed to show because there was a Point Percentage in another month that fulfilled the filter requirement.

I was able to rewrite the query as such to get the desired results:

SELECT 
  NON EMPTY 
    Filter
    (
      {
          [Program].[ByRegion].[Program]*
          [Performance Metric].[Metric].Children*
          [Calendar Period].[Y-Q-M].[Month of Quarter].&[3]&[1]&[2009]
      }
     ,
      [Measures].[Point Percentage] < 0.95
    ) ON ROWS
 ,NON EMPTY 
    [Measures].[Point Percentage] ON COLUMNS
FROM [QEP Revenue];

Luckily, this query is being used in reporting services, so it is appropriate to move the Calendar Period into the ROWS. However, if I wanted to keep the Calendar Period in the COLUMNS, I wouldn't know how to solve this since the same dimension cannot be used in both axes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文