请教MDX查询最近12个月有销售额的客户集的写法

0
需求是 得到在最近12个月有销售额 且在最近3个月没有销售额的客户。
思路是 先建一个最近12个月有销售额的客户集 A,然后建立一个最近三个月有销售额的客户集B。
A-B就是所求的客户。查询  最近12个月有销售额的客户。 我写的MDX如下。
查询出来的客户 包含了销售额是null的。
新建位图图像.jpg

with 
--当前日期
member [Measures].[当前日期] as now() 
--最近12个月集合
set Last12Month as 
StrToMember("[业务日期].[月].&["+Format(DateAdd('m',-12,CDATE([Measures].[当前日期])),"yyyyMM")+"]" )
:StrToMember("[业务日期].[月].&["+Format([Measures].[当前日期],"yyyyMM" )+"]")
--创建最近12个月有销售额的客户集
set CustomersLast12Month as
Filter ([客户].[客户名称].Members,Not isEmpty(Last12Month))
--Filter ([客户].[客户名称].Members,Not isEmpty([Measures].[金额(发出)]))
select CustomersLast12Month on 0 
from  [wegodw]
where [Measures].[金额(发出)]
 
 
修改MDX后 可以查出,但是客户是重复的,怎样去掉重复的客户 不显示日期列

新建位图图像.jpg

 
with 
--当前日期
member [Measures].[当前日期] as now() 
--最近12个月集合
set Last12Month as 
    StrToMember("[业务日期].[月].&["+Format(DateAdd('m',-12,CDATE([Measures].[当前日期])),"yyyyMM")+"]" )
    :StrToMember("[业务日期].[月].&["+Format([Measures].[当前日期],"yyyyMM" )+"]")

--创建最近12个月有销售额的客户集
set CustomersLast12Month as
    --filter ([客户].[客户名称].Members,not isEmpty(Last12Month))
    filter (
    CROSSJOIN({[客户].[客户名称].Members},{Last12Month}),
    not isEmpty( [Measures].[金额(发出)])
    )

select  [Measures].[金额(发出)]  on 0,CustomersLast12Month on 1
from  [wegodw]
 
 
已邀请:

要回复问题请先登录注册