MDX 使用 except 不起作用

发布于 2024-12-26 07:54:48 字数 1710 浏览 5 评论 0原文

我遇到以下问题:

Select
    {
        [Measures].[PerformanceTotalYtd]

    } on columns,

    Non Empty{  
       Except(([Desk].[DeskName].[Trade].Members,[Time].[Year-Month-Day].[Day].&[2012]&[1]&[10]),([Desk].[DeskName].[Trade].Members,[Time].[Year-Month-Day].[Day].&[2012]&[1]&[09]))
    } on rows

from [Cube]

where ([Entity].[Entity].&[9], [Audience].[View].&[GOD])

存在一个名为 Name Desk 的维度。此维度有一个名为 DeskName 的层次结构。最低级别是贸易。

Desk: -Total -Segment -BusinessArea -Department -4th Level Portfolio -Desk -Trade

通过下面显示的查询,我想显示在 2012/01/10 日期具有度量“PerformanceTotalYtd”!= NULL 的所有交易交易日期为“PerformanceTotalYtd”!= NULL 的交易除外2012/01/09 !

示例:

在 2012/01/10 上使用 Measure PerformanceTotalYtd 进行交易:

ABC 12,99

DEF 3,22

GHI 55,60

在 2012/01/09 上使用 Measure PerformanceTotalYtd 进行交易:

ABC 80,00

DEF 8,78

我想要以下内容结果是因为交易“GHI”不存在2012/01/09 是新的:

GHI 55,60

下面显示的我的查询有以下结果:

ABC 12,99

DEF 3,22

GHI 55,60

它不会删除 2012/01/09 中的现有交易。

我有一个 SQL 解决方案,但想在 MDX 中实现:

    SELECT DD.Code, Sum(PerformanceTotalYtd) as TOTAL
      FROM [Reporting_DB].[Star].[Fact_PerformanceTotal] FIS
            inner join Star.Dimension_Desk DD on FIS.DeskID = DD.DeskID
      WHERE FIS.TimeID = 20120110 and FIS.EntityID = 9 AND DD.Code not in ( SELECT DD.Code
FROM [Reporting_DB_HRE].[Star].[Fact_PerformanceTotal] FIS inner join Star.Dimension_Desk DD on FIS.DeskID = DD.DeskID WHERE FIS.TimeID = 20120109 and FIS.EntityID = 9 group by DD.Code)group by DD.Code

有人可以帮助我吗?我找不到解决办法。

抱歉我的英语不好!

亚历克斯

I have the following Problem:

Select
    {
        [Measures].[PerformanceTotalYtd]

    } on columns,

    Non Empty{  
       Except(([Desk].[DeskName].[Trade].Members,[Time].[Year-Month-Day].[Day].&[2012]&[1]&[10]),([Desk].[DeskName].[Trade].Members,[Time].[Year-Month-Day].[Day].&[2012]&[1]&[09]))
    } on rows

from [Cube]

where ([Entity].[Entity].&[9], [Audience].[View].&[GOD])

It exists a Dimension with the Name Desk. This Dimension has a Hierarchy with the name DeskName. The lowest Level ist Trade.

Desk: -Total -Segment -BusinessArea -Department -4th Level Portfolio -Desk -Trade

With the Query showing below, i want to show all Trades, that have the Measure "PerformanceTotalYtd" != NULL on the Date of 2012/01/10 except the Trades with the Measure "PerformanceTotalYtd" != NULL on the Date of 2012/01/09 !

Example:

Trades with Measure PerformanceTotalYtd on the 2012/01/10:

ABC 12,99

DEF 3,22

GHI 55,60

Trades with Measure PerformanceTotalYtd on the 2012/01/09:

ABC 80,00

DEF 8,78

I want the following Result because the Trade "GHI" doesn't exists on the 2012/01/09 and is new:

GHI 55,60

My Query showing below have this result:

ABC 12,99

DEF 3,22

GHI 55,60

It doesn't delete the existing Trades from the 2012/01/09.

I have a Solution in SQL but want to make it in MDX:

    SELECT DD.Code, Sum(PerformanceTotalYtd) as TOTAL
      FROM [Reporting_DB].[Star].[Fact_PerformanceTotal] FIS
            inner join Star.Dimension_Desk DD on FIS.DeskID = DD.DeskID
      WHERE FIS.TimeID = 20120110 and FIS.EntityID = 9 AND DD.Code not in ( SELECT DD.Code
FROM [Reporting_DB_HRE].[Star].[Fact_PerformanceTotal] FIS inner join Star.Dimension_Desk DD on FIS.DeskID = DD.DeskID WHERE FIS.TimeID = 20120109 and FIS.EntityID = 9 group by DD.Code)group by DD.Code

Can anybody help me please? I can't find a solution.

Sorry for my bad english!

Alex

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

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

发布评论

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

评论(2

一世旳自豪 2025-01-02 07:54:48

我在 Adventure Works 立方体中找到了类似的示例:
集合 {[客户].[城市].&[贝尔花园]&[CA], [客户].[城市].&[贝尔维尤]&[WA], [客户].[ City].&[Bellflower]&[CA]}[Measures].[Internet Sales Amount] 有 3 个值[日期].[日历年].&[2002],并且 [日期].[日历年].&[2004] 中只有 2 个值。因此,我们需要显示 2002 年成员的测量值,其中 2004 年的测量值 == null。
下一个 MDX 查询达到了预期的结果:

with set S as '{[Customer].[City].&[Bell Gardens]&[CA], [Customer].[City].&[Bellevue]&[WA], [Customer].[City].&[Bellflower]&[CA]}'
select
[Measures].[Internet Sales Amount] on 0,
non empty { Filter(S, IsEmpty(([Date].[Calendar Year].&[2004], [Measures].[Internet Sales Amount]))) } on 1
from [Adventure Works]
where ([Date].[Calendar Year].&[2002])

我尝试相应地修改您的示例,但无法测试它。简而言之:

select
{ [Measures].[PerformanceTotalYtd] } on 0,
non empty { Filter([Desk].[DeskName].[Trade].Members, IsEmpty(([Time].[Year-Month-Day].[Day].&[2012]&[1]&[09], [Measures].[PerformanceTotalYtd]))) } on 1
from [Cube]
where ([Entity].[Entity].&[9], [Audience].[View].&[GOD], [Time].[Year-Month-Day].[Day].&[2012]&[1]&[10])

使用 Filter 而不是 except。

I have found a similar example in the Adventure Works cube:
The set {[Customer].[City].&[Bell Gardens]&[CA], [Customer].[City].&[Bellevue]&[WA], [Customer].[City].&[Bellflower]&[CA]} has 3 values for [Measures].[Internet Sales Amount] in [Date].[Calendar Year].&[2002], and only 2 values in [Date].[Calendar Year].&[2004]. So we need to show measure value for member in 2002 where measure value == null in 2004.
The next MDX query achieves the desired result:

with set S as '{[Customer].[City].&[Bell Gardens]&[CA], [Customer].[City].&[Bellevue]&[WA], [Customer].[City].&[Bellflower]&[CA]}'
select
[Measures].[Internet Sales Amount] on 0,
non empty { Filter(S, IsEmpty(([Date].[Calendar Year].&[2004], [Measures].[Internet Sales Amount]))) } on 1
from [Adventure Works]
where ([Date].[Calendar Year].&[2002])

I tried to modify your example accordingly, but can't test it. Here it is:

select
{ [Measures].[PerformanceTotalYtd] } on 0,
non empty { Filter([Desk].[DeskName].[Trade].Members, IsEmpty(([Time].[Year-Month-Day].[Day].&[2012]&[1]&[09], [Measures].[PerformanceTotalYtd]))) } on 1
from [Cube]
where ([Entity].[Entity].&[9], [Audience].[View].&[GOD], [Time].[Year-Month-Day].[Day].&[2012]&[1]&[10])

In short: use Filter instead of Except.

星光不落少年眉 2025-01-02 07:54:48

我有解决我的问题的方法。以下查询显示与 Dmitry Polyanitsa 的查询相同的结果!祝大家有美好的一天!

with
    set [Trades Today] as NonEmpty([Desk].[DeskName].[Trade].Members,  ([Measures].[PerformanceTotalYtd], [Time].[Year-Month-Day].[Day].&[2012]&[1]&[10]))
    set [Trades Yesterday] as NonEmpty([Desk].[DeskName].[Trade].Members,  ([Measures].[PerformanceTotalYtd], [Time].[Year-Month-Day].[Day].&[2012]&[1]&[9]))
    set [Trades Difference] as Except([Trades Today], [Trades Yesterday])

Select
    {
        [Measures].[PerformanceTotalYtd]

    } on columns,

    Non Empty{  
       [Trades Difference]
    } on rows

from [Cube]

where ([Entity].[Entity].&[9], [Audience].[View].&[GOD])

I have the Solution for my Problem. Following Query shows the same Result as the Query of Dmitry Polyanitsa! Have a nice Day guys!

with
    set [Trades Today] as NonEmpty([Desk].[DeskName].[Trade].Members,  ([Measures].[PerformanceTotalYtd], [Time].[Year-Month-Day].[Day].&[2012]&[1]&[10]))
    set [Trades Yesterday] as NonEmpty([Desk].[DeskName].[Trade].Members,  ([Measures].[PerformanceTotalYtd], [Time].[Year-Month-Day].[Day].&[2012]&[1]&[9]))
    set [Trades Difference] as Except([Trades Today], [Trades Yesterday])

Select
    {
        [Measures].[PerformanceTotalYtd]

    } on columns,

    Non Empty{  
       [Trades Difference]
    } on rows

from [Cube]

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