我可以重新配置此MDX查询以使用集而不是“和”吗?

时间:2010-07-14 13:58:35

标签: ssas data-mining mdx

with member [Measures].[BoughtDispenser] as
    Sum(Descendants([Customer].[Customer].CurrentMember, [Customer].[Customer]),
        Iif(
            (IsEmpty(([Item].[ItemNumber].&[011074], [Measures].[Sale Amount]))
            And IsEmpty(([Item].[ItemNumber].&[011069], [Measures].[Sale Amount]))
            )
            Or IsEmpty([Measures].[Sale Amount]),
            0 , 1
        )
    )
select 
{[Measures].[Sale Amount]} on columns,
non empty filter([Customer].[Customer].children, [Measures].[BoughtDispenser])
    * {[Item].[ItemNumber].members}
on rows
from [Sales]
where [EnteredDate].[Quarter].&[2010-01-01T00:00:00]
;

目标是显示同时购买两台掌柜(011069和011074)中任何一台的客户购买的所有物品。

我将计算成员基于我发现进行篮子分析的查询。我觉得应该有一种方法用set {[Item]。[ItemNumber]。& [011074],[Item]。[ItemNumber]。& [011069]}来代替两个IsEmpty测试。我尝试的所有内容最终都让每个客户都参与其中。

我的环境是SQL Server Analysis Services 2005。

1 个答案:

答案 0 :(得分:0)

是的,我可以!它只需要一个与计算成员略有不同的方法:

with member [Measures].[BoughtDispenser] as
    Sum(Descendants([Customer].[Customer].CurrentMember, [Customer].[Customer])
        * {[Item].[ItemNumber].&[011069], [Item].[ItemNumber].&[011074]},
        [Measures].[Quantity Shipped]
    )
select 
{[Measures].[Sale Amount]} on columns,
non empty filter([Customer].[Customer].children, [Measures].[BoughtDispenser])
    * {[Item].[ItemNumber].members}
on rows
from [Sales]
where [EnteredDate].[Quarter].&[2010-01-01T00:00:00]
;