在MDX中设置第一个元组成员

时间:2017-02-19 08:47:02

标签: set tuples extract mdx

我是Mdx查询的新手,我有一个关于mdx的问题,如何在集合中将元组的第一个成员提取为mdx中的新集合? 我有这样的查询:

WITH
     SET [people in first date] AS   
   'Filter  
      (  
       {[VW Dim Customer Broker Branch].[Customer Title].[Customer Title]*[Vw Dim Date].[Shamsi Date].&[1388/06/01]:[Vw Dim Date].[Shamsi Date].&[1388/06/02]},
       [Measures].[Trade Cnt]>3
      ) ' 

       SET [people in second date] AS   
   'Filter  
      (  
       {[VW Dim Customer Broker Branch].[Customer Title].[Customer Title]*[Vw Dim Date].[Shamsi Date].&[1388/06/03]:[Vw Dim Date].[Shamsi Date].&[1388/06/04]},
       [Measures].[Trade Cnt]>0
      ) ' 

     /* SET [numberOfFirstItem] As
      [people in first date].item(0)*/

     member [measures].[numberOfPeopleInFirstDate] AS
    DistinctCount([people in first date])

    member [measures].[numberOfPeopleInFirstDate1] AS
    Count([people in first date])

     member [measures].[numberOfPeopleInSecondtDate] AS
     DistinctCount([people in second date])

     member [measures].[Ratio] AS 
     '(([measures].[numberOfPeopleInSecondtDate]-[measures].[numberOfPeopleInFirstDate])/IIF([measures].[numberOfPeopleInFirstDate]=0,1,[measures].[numberOfPeopleInFirstDate]))*100'

 select
       [Measures].[Trade Cnt] on 0,
       [people in first date] on 1 
       --{[measures].[numberOfPeopleInFirstDate],[measures].[numberOfPeopleInSecondtDate],[measures].[Ratio]} on 0 
      /* {[Measures].[Trade Cnt]} on 0,
       [people in first date] on 1*/
      -- {[numberOfFirstItem]} on 0

      from [DVPL]

我想在第一组中提取tuples的第一个成员 - 只有[VW Dim Customer Broker Branch].[Customer Title].[Customer Title],因为我想要将people的计数名称与提到的查询T一起收到重复名称。

1 个答案:

答案 0 :(得分:1)

如果我理解正确,您希望得到所有[VW Dim Customer Broker Branch]的不同数量。[客户名称]。[客户名称]仅限等级成员。在这里根本不使用元组逻辑更容易。我创建了一个措施来获得第一个日期所有成员的明确计数,以及第一个日期和第二个日期的明显计数,加上他们的口粮,显然:

Member [Measures].[NumberOfPeopleInFirstDate] as
SUM(
    existing [VW Dim Customer Broker Branch].[Customer Title].[Customer Title].Members,
    IIF(
        Aggreagate(
            [Vw Dim Date].[Shamsi Date].&[1388/06/01]:[Vw Dim Date].[Shamsi Date].&[1388/06/02],
            [Measures].[Trade Cnt]
        ) > 3,
        1,
        NULL
    )
)


Member [Measures].[NumberOfPeopleInFirstDateAndSecondDate] as
SUM(
    existing [VW Dim Customer Broker Branch].[Customer Title].[Customer Title].Members,
    IIF(
        AGGREGATE(
            [Vw Dim Date].[Shamsi Date].&[1388/06/01]:[Vw Dim Date].[Shamsi Date].&[1388/06/02],
            [Measures].[Trade Cnt]
        ) > 3
        and
        AGGREGATE(
            [Vw Dim Date].[Shamsi Date].&[1388/06/03]:[Vw Dim Date].[Shamsi Date].&[1388/06/04],
            [Measures].[Trade Cnt]
        ) > 0,
        1,
        NULL
    )
)

Member [Measures].[Ratio] as
[Measures].[NumberOfPeopleInFirstDateAndSecondDate] / [Measures].[NumberOfPeopleInFirstDate]