where条件的不同部分适用于mdx查询的不同部分

时间:2017-05-23 07:37:40

标签: where mdx

我是mdx中的新手,我有疑问将两个条件放在mdx查询的不同部分中的应用位置。 在我的查询中我有两个设置(包括从日期:到日期),我想首先应用第一个成员,第二个设置为第二个成员,但我不想在成员中创建元组,因为我想计算总和衡量每个客户。 当我把条件放在哪里,只有一个日期适用于会员我想申请不同的条件适用于不同的会员。 我怎样才能做到这一点?

WITH 
SET BaseDate AS
  [Vw Dim Date].[Shamsi Date].&[1396/02/22] :  [Vw Dim Date].[Shamsi Date].&[1396/03/19]

SET CompareDate AS
    [Vw Dim Date].[Shamsi Date].&[1396/01/21] :  [Vw Dim Date].[Shamsi Date].&[1396/02/19]


MEMBER TotalCustomerCntInBase AS 
   Sum(BaseDate.item(count(BaseDate)-1) ,[Measures].[Total Customer Cnt])

MEMBER TotalCustomerCntInCompare AS 
   Sum(CompareDate.item(count(CompareDate)-1) ,[Measures].[Total Customer Cnt])


member numberOfActivecustomers as 
count(filter (nonempty([Vw Customer].[Customer BK].[Customer BK],[Measures].[Trade Cnt]),[Measures].[Trade Cnt]=1))

select {numberOfActivecustomers} on 0
from [DV Present]
where ([Vw Dim Date].[Shamsi Date].&[1395/01/01]:[Vw Dim Date].[Shamsi Date].&[1395/02/01])

1 个答案:

答案 0 :(得分:0)

为了总结天数,您可以创建两个计算成员(句点)并针对它们运行任何度量:

With 
Member [Vw Dim Date].[Shamsi Date].[BaseDate] as
Sum(
    [Vw Dim Date].[Shamsi Date].&[1396/02/22]:
    [Vw Dim Date].[Shamsi Date].&[1396/03/19]
)

Member [Vw Dim Date].[Shamsi Date].[CompareDate] as
Sum(
    [Vw Dim Date].[Shamsi Date].&[1396/01/21]:
    [Vw Dim Date].[Shamsi Date].&[1396/02/19]
)

// Add here any calculations you need ...

Select 
{[Measures].[Trade Cnt]} on 0,
{[Vw Dim Date].[Shamsi Date].[CompareDate],[Vw Dim Date].[Shamsi Date].[CompareDate]} on 1 
from [DV Present]