如何使用相同的维度获得Measure计数的组合

时间:2014-12-08 12:58:29

标签: sql-server ssas mdx olap cube

如何在MDX中获得Dimensions Measure计数的所有组合。在下面的图像中,我得到了单独的值测量计数但是我如何得到值的组合测量count.Say例如我有262,210和198 DrKey Dimension的个别值计数。我将需要值计数组合像 1)262和210以及测量计数 2)262和198along与测量计数 3)198和210以及测量计数 4)262,210和198以及测量计数 enter image description here

我的以下查询:

WITH 
  MEMBER DrKey AS 
    [DimPopulation].[Population Key].CurrentMember.Member_Key 
  MEMBER [Measures].[DrList] AS 
    NonEmpty
    (
      {[DimPopulation].[Population Key].&[262], [DimPopulation].[Population Key].&[210]}
     ,[Measures].[DrPatientKeyCnt]
    ) 
SELECT 
  {
    DrKey
   ,[Measures].[DrPatientKeyCnt]
   ,DrList
  } ON COLUMNS
 ,NonEmpty
  (
    {
      [DimPopulation].[Population Key].&[262]
     ,[DimPopulation].[Population Key].&[210]
     ,[DimPopulation].[Population Key].&[198]
    }
   ,[Measures].[DrPatientKeyCnt]
  ) ON ROWS
FROM [abc]
WHERE 
  (
    [DimAnchorDate].[Date Key].&[20141031]
   ,[DimReport].[Report Key].&[1]
  );

2 个答案:

答案 0 :(得分:1)

是否仍然显示错误?

//WITH 
  //MEMBER DrKey AS 
    //[DimPopulation].[Population Key].CurrentMember.Member_Key 

WITH
 MEMBER [Measures].[DrList] AS 
    NonEmpty
    (
      {[DimPopulation].[Population Key].&[262], [DimPopulation].[Population Key].&[210]}
     ,[Measures].[DrPatientKeyCnt]
    ) 


SELECT 
  {
    //DrKey,
   [Measures].[DrPatientKeyCnt]
   ,DrList
  } ON COLUMNS
 ,NonEmpty
  (
    {
      [DimPopulation].[Population Key].&[262]
     ,[DimPopulation].[Population Key].&[210]
     ,[DimPopulation].[Population Key].&[198]
    }
   ,[Measures].[DrPatientKeyCnt]
  ) ON ROWS
FROM [abc]
WHERE 
  (
    [DimAnchorDate].[Date Key].&[20141031]
   ,[DimReport].[Report Key].&[1]
  );

答案 1 :(得分:0)

尝试在元组周围使用aggregate函数:

WITH 
  MEMBER DrKey AS 
    [DimPopulation].[Population Key].CurrentMember.Member_Key 
  MEMBER [Measures].[DrList] AS 
    AGGREGATE(        
      NonEmpty
      (
      {[DimPopulation].[Population Key].&[262], [DimPopulation].[Population Key].&[210]}
     ,[Measures].[DrPatientKeyCnt]
      ) 
    )
SELECT 
  {
    DrKey
   ,[Measures].[DrPatientKeyCnt]
   ,DrList
  } ON COLUMNS
 ,NonEmpty
  (
    {
      [DimPopulation].[Population Key].&[262]
     ,[DimPopulation].[Population Key].&[210]
     ,[DimPopulation].[Population Key].&[198]
    }
   ,[Measures].[DrPatientKeyCnt]
  ) ON ROWS
FROM [abc]
WHERE 
  (
    [DimAnchorDate].[Date Key].&[20141031]
   ,[DimReport].[Report Key].&[1]
  );