MDX过滤器问题

发布于 2024-07-08 02:48:57 字数 1375 浏览 3 评论 0原文

我对整个 MDX 还很陌生,但下面的内容简直让我抓狂。 我正在使用的 FILTER 语句的行为......很奇怪。 代码示例,后跟说明:

SELECT
    {
        FILTER(
            MEMBERS([Time].[5-4-4 Week Year]),
            [Measures].[Ship Gross Units] > 0
        )
    }
    ON COLUMNS,
    {
        FILTER(
            MEMBERS([Group].[Alternate Hierarchies]),
            [Measures].[Ship Gross Units] > 0
        )
    }
    ON ROWS
FROM SBD.SBD
WHERE
    (
        [FiscalYear].[FY09],
        [Scenario].[Actuals Total],
        [Measures].[Ship Gross Units],
        [Channel].[FOS]
    )

我试图按财政年度的一周提取特定销售渠道的总单位数(某些列稍微混淆)。 所有这些过滤器都已就位,因为我经常需要在 SKU 级别分解这些过滤器,并且在我的计算机上处​​理截断的数据集更简单(我说,让数据库来完成工作!)。

问题是,此查询返回 FOS 渠道中的 0 销售额。 这看起来很奇怪,所以我删除了行过滤器:

SELECT
    {
        FILTER(
            MEMBERS([Time].[5-4-4 Week Year]),
            [Measures].[Ship Gross Units] > 0
        )
    }
    ON COLUMNS,
    MEMBERS([Group].[Alternate Hierarchies])
    ON ROWS
FROM SBD.SBD
WHERE
    (
        [FiscalYear].[FY09],
        [Scenario].[Actuals Total],
        [Measures].[Ship Gross Units],
        [Channel].[FOS]
    )

突然间,销售额出现在 FOS 渠道中。 这让我大吃一惊; 以前,我假设我正在过滤以仅接收显示销售的行,但我什么也没有得到。 现在我正在显示所有内容,并且有一些带有销售的行。 使用 Perl 或其他语言解决这个问题很容易,但我宁愿“正确”地解决它。

我相当确定我只是误解了一些琐碎的细节,但我厌倦了用头撞桌子。

谢谢!

I'm pretty new to the whole MDX thing, but the following is just driving me batty. A FILTER statement I'm using is acting... strangely. Code sample, followed by description:

SELECT
    {
        FILTER(
            MEMBERS([Time].[5-4-4 Week Year]),
            [Measures].[Ship Gross Units] > 0
        )
    }
    ON COLUMNS,
    {
        FILTER(
            MEMBERS([Group].[Alternate Hierarchies]),
            [Measures].[Ship Gross Units] > 0
        )
    }
    ON ROWS
FROM SBD.SBD
WHERE
    (
        [FiscalYear].[FY09],
        [Scenario].[Actuals Total],
        [Measures].[Ship Gross Units],
        [Channel].[FOS]
    )

I'm trying to pull gross units for a particular sales channel, by week of the fiscal year (some columns obfuscated slightly). All those filters are in place due to the fact that I often need these broken out at the SKU level, and it's simpler to deal with a truncated dataset on my machine (let the DB do the work, I say!).

The problem is, this query returns 0 sales in the FOS channel. That seemed strange, so I removed the row filter:

SELECT
    {
        FILTER(
            MEMBERS([Time].[5-4-4 Week Year]),
            [Measures].[Ship Gross Units] > 0
        )
    }
    ON COLUMNS,
    MEMBERS([Group].[Alternate Hierarchies])
    ON ROWS
FROM SBD.SBD
WHERE
    (
        [FiscalYear].[FY09],
        [Scenario].[Actuals Total],
        [Measures].[Ship Gross Units],
        [Channel].[FOS]
    )

And all of a sudden, sales show up in the FOS channel. This blows my mind; previously, I'd assumed I was filtering to just receive rows showing sales, and I got none. Now I'm showing everything, and there are rows with sales. It's easy enough to work around this problem with Perl or whatever, but I'd rather solve it "right".

I'm reasonably certain I'm just misunderstanding some niggling detail, but I'm tired of bashing my head against the desk.

Thanks!

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

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

发布评论

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

评论(1

时光沙漏 2024-07-15 02:48:57

我通常使用 Microsoft Analysis Services,但 MDX 通常与 Essbase 中使用的非常相似。

轴将被独立评估,因此 Group 上的过滤语句将仅查看 where 子句中的成员。 那么,2009 财年的总单位数是否有可能存在一些负值并且小于或等于 0? 或者您的单位计数是否足够大,以至于它们可能会溢出数据类型并返回负数?

如果您只是查找非空单元格,一种可能的解决方法是在轴上使用 NON EMPTY 关键字。
例如。

SELECT    
   NON EMPTY MEMBERS([Time].[5-4-4 Week Year]),
     ON COLUMNS,
   NON EMPTY  MEMBERS([Group].[Alternate Hierarchies])
     ON ROWS
FROM SBD.SBD
WHERE
    (
        [FiscalYear].[FY09],
        [Scenario].[Actuals Total],
        [Measures].[Ship Gross Units],
        [Channel].[FOS]
    )

I usually work with Microsoft Analysis Services, but the MDX is generally very similar to that used in Essbase.

The axis will be getting evaluated independantly, so the filter statement on Group will be looking at only the members in the where clause. So is it possible that either your Gross Units have some negatives and are less than or equal to 0 for FY09? Or are your unit counts large enough that they are potentially overflowing the data type and wrapping around to negative numbers?

One possible work around if you are just looking for non-empty cells is to use the NON EMPTY keyword on the axis.
eg.

SELECT    
   NON EMPTY MEMBERS([Time].[5-4-4 Week Year]),
     ON COLUMNS,
   NON EMPTY  MEMBERS([Group].[Alternate Hierarchies])
     ON ROWS
FROM SBD.SBD
WHERE
    (
        [FiscalYear].[FY09],
        [Scenario].[Actuals Total],
        [Measures].[Ship Gross Units],
        [Channel].[FOS]
    )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文