我有以下问题:
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])
它与名称服务台存在一个维度。此Dimension具有名为DeskName的层次结构。最低级别是贸易。
服务台:-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 53,50
在2012/01/09上与Measure PerformanceTotalYtd进行交易:
ABC 80,00
DEF 8,78
我想要以下结果,因为2012/01/09上没有交易“GHI”并且是新的:
GHI 53,50
我的查询显示如下:
ABC 12,99
DEF 3,22
GHI 53,50
它不会删除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
是的,有人可以帮帮我吗?我找不到解决方案。
抱歉我的英文不好!
亚历
答案 0 :(得分:2)
我在Adventure Works多维数据集中找到了一个类似的例子:
集合{[Customer].[City].&[Bell Gardens]&[CA], [Customer].[City].&[Bellevue]&[WA], [Customer].[City].&[Bellflower]&[CA]}
在[Measures].[Internet Sales Amount]
中有[Date].[Calendar Year].&[2002]
的3个值,在[Date].[Calendar Year].&[2004]
中只有2个值。因此,我们需要在2002年显示成员的度量值,其中度量值== 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。
答案 1 :(得分:1)
我有解决问题的方法。以下查询显示与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])