2017-06-29 135 views
0

我正在写一些MDX加入维度基于两个不同时期本身得到一个共同的名单,然后做一个计数根据此列表两种。MDX加入具有相同尺寸

总之,我需要

  • 得到PERIOD1 Student.UniqueId的列表,其具有设定未在PERIOD2数据中设置一个标志(IsValid的)
  • 得到充分的对于PERIOD2
  • 学生的名单加入了两个列表,并产生两个记录(每个周期)具有相同数量(这些计数将用于各个周期内计算成员计算)

我试图通过再选择这样做,并存在子句过滤

SELECT 
{ 
    [Measures].[FactStudentCount] 
} on COLUMNS, 
{ NONEMPTY 
    (
     [TestEvent].[TestEvents].[Name].ALLMEMBERS 
     * [TestEvent].[PeriodName].[PeriodName].ALLMEMBERS 
    )        
} ON ROWS 
FROM (SELECT ({ 
    exists 
    (
     filter([Student].[UniqueId].[UniqueId].MEMBERS 
      ,([TestEvent].[Key].&[Period1], [IsValid].[Code].&[Yes])) 
     , 
     filter([Student].[UniqueId].[UniqueId].MEMBERS 
      ,[TestEvent].[Key].&[Period2]) 
    ) 
    }) ON COLUMNS 
FROM [MyCube]) 

......然而,这并没有给出正确的结果

(为了获得上下文)我也曾尝试类似存在内/过滤器where子句

SELECT 
{ 
    [Measures].[FactStudentCount] 
} on COLUMNS, 
{ NONEMPTY 
    (
     [TestEvent].[TestEvents].[Name].ALLMEMBERS 
     * [TestEvent].[PeriodName].[PeriodName].ALLMEMBERS 
    )        
} ON ROWS 
FROM [MyCube] 
where (
    exists 
    (
     filter([Student].[UniqueId].[UniqueId].MEMBERS 
      ,([TestEvent].[Key].&[Period1], [IsValid].[Code].&[Yes])) 
     , 
     filter([Student].[UniqueId].[UniqueId].MEMBERS 
      ,[TestEvent].[Key].&[Period2]) 
    ) 
) 

...但是这一次不会产生正确的结果

我试图调整过滤语句(中存在)送omething像

(filter(existing([Student].[UniqueId].[UniqueId].allmembers),[TestEvent].[Key].CurrentMember.MemberValue = 'Period1'), [IsValid].[Code].&[Yes]) 
, 
(filter(existing([Student].[UniqueId].[UniqueId].allmembers),[TestEvent].[Key].CurrentMember.MemberValue = 'Period2')) 

......然而,这仅返回一行(用于PERIOD1) - 这表示它是正确的总

我还通过与非空,CROSSJOIN试图然而,因为田野里失败同一层级 - 消息“密钥层次结构在交叉连接功能使用一次以上”

是否有任何人有任何深入了解如何解决上面的场景?

回答

0

这是我做过什么

NonEmpty(
    NonEmpty(
     {([Student].[UniqueId].[UniqueId].members)},{([TestEvent].[Key].&[Period1], [IsValid].[Code].&[Yes])} 
    ) 
    , 
    {([Student].[UniqueId].[UniqueId].members,[TestEvent].[Key].&[Period2])} 
) 

这得到所有PERIOD1元素,用的IsValid =“是”,那么在PERIOD2

“左加入”这与记录