第二个MDX查询必须返回第一个MDX查询返回的每一行的结果

时间:2011-09-12 17:22:54

标签: ssas mdx

我有一个情况,我正在寻找MDX指导。

环境:SQL Server 2008 R2,SSRS 2008 R2

尺寸:列 DimMainProvider:ProviderName DimAcademicYear:AcademicYear DimSectorSubjectArea:Estyn DimLearningAim:LearningAimReference

事实:列 学习:MainProviderKey,AgeBandKey,LearningAimKey,SuccessFlag

我想要的是什么     1)对于特定的MainProvider按成功率获取前10个LearningAims并在tablix中显示     2)对于tablix上的每一行,还显示Box plot图,它基本上需要所有Mainproviders中特定LearningAim的Min,Max,Quartile1,Quartile3成功率

我所拥有的是2个MDX查询

  

a)获得主要提供者的前10个活动(简化版)   下面的MDX版本)

WITH
SET Top10LearningAimsForSuccessRate
AS 
NonEmpty(
        TOPCOUNT([ReportedLearningAims],10,[Measures].[SuccessRate]),
        [Measures].[SuccessRate]
        )
SELECT 
    {
      [Measures].[SuccessRate]
    } ON COLUMNS

 ,NON EMPTY 
    {  
        EXISTS( 
                Top10LearningAimsForSuccessRate
               ,,"Learnings")
     } ON ROWS
FROM 
(

SELECT {[Measures].[TerminatedAssessableLASum]
     ,[Measures].[SuccessfulLASum]} ON COLUMNS
     ,{(StrToSet("[DimMainProvider].[ProviderName].&[44]",CONSTRAINED))} On ROWS
FROM [FECube]
)
WHERE 
  ( StrToSet("[DimAcademicYear].[AcademicYear].[AcademicYear].[2009/10]",CONSTRAINED), 
    StrToSet("[DimSectorSubjectArea].[Estyn].&[2]",CONSTRAINED)
  )
  

b)另一个接受LearningAim作为参数的查询   统计计算并给出我的值(简化版本   下面的MDX)

WITH 
SET ProviderwideLearningAims
AS
ORDER(
        NonEmpty( [DimMainProvider].[ProviderName].[ProviderName],
                  [Measures].[SuccessRate]
                )
        ,[Measures].[SuccessRate],BASC        
    )

MEMBER [Measures].[MaxValue]
AS
Max(ProviderwideLearningAims,[SuccessRate]),FORMAT_STRING = "Percent"

MEMBER [Measures].[MinValue]
AS
Min(ProviderwideLearningAims,[SuccessRate]),FORMAT_STRING = "Percent"

MEMBER [Measures].[MedianValue]
AS
Median(ProviderwideLearningAims,[SuccessRate]),FORMAT_STRING = "Percent"


Member [Measures].[ProviderCount] As [ProviderwideLearningAims].Count   

MEMBER [Measures].[MeanValue]
AS 
(SUM(ProviderwideLearningAims,[SuccessRate])/[Measures].[ProviderCount]),FORMAT_STRING = "Percent"


MEMBER [Measures].[LearningAimUniqueName]
AS
[DimLearningAim].[LearningAimReference].CurrentMember.UniqueName                                  

Select
        {     [Measures].[LearningAimUniqueName]
             ,[Measures].[MinValue]     
             ,[Measures].[MaxValue]
             ,[Measures].[MedianValue]
             ,[Measures].[MeanValue]

        } ON COLUMNS,

       {
        NonEmpty([DimLearningAim].[LearningAimReference].[LearningAimReference],ProviderwideLearningAims)
       } ON ROWS
FROM
(
   SELECT 
   StrToSet("[DimLearningAim].[LearningAimReference].&[50024991]",CONSTRAINED) ON COLUMNS
   FROM [FECube]
   )
WHERE 
  ( StrToSet("[DimAcademicYear].[AcademicYear].[AcademicYear].[2009/10]",CONSTRAINED), 
    StrToSet("[DimSectorSubjectArea].[Estyn].&[2]",CONSTRAINED)

  )
  

我最初的想法是针对收到的每个学习目标触发第二个查询   来自第一个查询,但我无法在SSRS数据集中实现此功能   模型。   所以现在我回到MDX级别,并希望以某种方式合并这些   2。

1 个答案:

答案 0 :(得分:0)

以下是我在MSDN论坛上使用Deepak Puri的帮助修复它的方法

  

将[Top10LearningAims]设置为TOPCOUNT(

     

筛选(([ReportedLearningAims] * [DimMainProvider] [的ProviderName] .MEMBERS),[DimMainProvider]。[的ProviderName] .CURRENTMEMBER   是STRTOMEMBER(“[DimMainProvider]。[ProviderName]。& [44]”))            ,10,[措施]。[TerminatedAssessableLASum]           )

     

会员[措施]。[MaxValue] AS   MAX(非空([DimMainProvider]。[的ProviderName]。[的ProviderName]   [Measures]。[SuccessRate]),[Measures]。[SuccessRate]),FORMAT_STRING =   “百分比”成员[测量]。[MinValue] AS   分钟(非空([DimMainProvider]。[的ProviderName]。[的ProviderName]   [Measures]。[SuccessRate]),[Measures]。[SuccessRate]),FORMAT_STRING =   “百分比”会员[测量]。[MedianValue] AS   中位数(非空([DimMainProvider]。[的ProviderName]。[的ProviderName]   [Measures]。[SuccessRate]),[Measures]。[SuccessRate]),FORMAT_STRING =   “百分比”

     

会员[措施]。[MeanValue] AS   AVG(非空([DimMainProvider]。[的ProviderName]。[的ProviderName]   [Measures]。[SuccessRate]),[Measures]。[SuccessRate]),FORMAT_STRING =   “百分比”

     

会员[Measures]。[ProviderCount] as   计数(非空([DimMainProvider]。[的ProviderName]。[的ProviderName]   [Measures]。[SuccessRate]))成员[Measures]。[PercentileInt25] as   Int((([Measures]。[ProviderCount] - 1)* 25)/ 100)会员   [措施]。[PercentileFrac25] as(([Measures]。[ProviderCount] - 1)*   25)/ 100    - [Measures]。[PercentileInt25]会员[Measures]。[PercentileLo25] as   ([措施]。[SuccessRate]   订单(非空([DimMainProvider]。[的ProviderName] [的ProviderName]   [Measures]。[SuccessRate]),[Measures]。[SuccessRate],   BASC).Item([Measures]。[PercentileInt25])。Item(0)),FORMAT_STRING =   “百分比”会员[措施]。[PercentileHi25] as   ([措施]。[SuccessRate]   订单(非空([DimMainProvider]。[的ProviderName] [的ProviderName]   [Measures]。[SuccessRate]),[Measures]。[SuccessRate],   BASC).Item([Measures]。[PercentileInt25] + 1).Item(0)),FORMAT_STRING =   “百分比”会员[措施]。[Percentile25Value] as   ([Measures]。[PercentileLo25] *(1 - [Measures]。[PercentileFrac25]))   +([Measures]。[PercentileHi25] * [Measures]。[PercentileFrac25]),   FORMAT_STRING =“百分比”成员[Measures]。[PercentileInt75] as   Int((([Measures]。[ProviderCount] - 1)* 75)/ 100)会员   [Measures]。[PercentileFrac75] as(([Measures]。[ProviderCount] - 1)*   75)/ 100    - [Measures]。[PercentileInt75]会员[Measures]。[PercentileLo75] as   ([措施]。[SuccessRate]   订单(非空([DimMainProvider]。[的ProviderName] [的ProviderName]   [Measures]。[SuccessRate]),[Measures]。[SuccessRate],   BASC).Item([Measures]。[PercentileInt75])。Item(0)),FORMAT_STRING =   “百分比”会员[措施]。[PercentileHi75] as   ([措施]。[SuccessRate]   订单(非空([DimMainProvider]。[的ProviderName] [的ProviderName]   [Measures]。[SuccessRate]),[Measures]。[SuccessRate],   BASC).Item([Measures]。[PercentileInt75] + 1).Item(0)),FORMAT_STRING =   “百分比”成员[Measures]。[Percentile75Value] as   ([Measures]。[PercentileLo75] *(1 - [Measures]。[PercentileFrac75]))   +([Measures]。[PercentileHi75] * [Measures]。[PercentileFrac75]),   FORMAT_STRING =“百分比”

     

选择{[Measures]。[TerminatedAssessableLASum]        ,[措施]。[SuccessfulLASum]        ,[措施]。[SuccessRate]        ,[措施]。[SectorTerminatedAssessableLASum]        ,[措施]。[SectorSuccessfulLASum]        ,[措施]。[SectorSuccessRate]        ,[Measures]。[ProviderCount],[Measures]。[MinValue]
  ,[Measures]。[MaxValue],[Measures]。[MeanValue]
  ,[措施]。[Percentile25Value],[Measures]。[MedianValue]
  ,[措施]。[Percentile75Value]}在COLUMNS上,   EXISTS(非空(([DimLearningAim] [LearningAimReference] [LearningAimReference],[DimLearningAim] [LearningAimTitle] [LearningAimTitle]),([Top10LearningAims],[措施]。[SuccessRate]))*非空([DimMainProvider] [的ProviderName]。[的ProviderName]   [测量]。[SuccessRate]),,“学习”)尺寸特性   MEMER_CAPTION,MEMBER_UNIQUE_NAME来自FECube WHERE
的行   (StrToSet(“[DimAcademicYear]。[AcademicYear]。[AcademicYear]。[2009/10]”,CONSTRAINED),     StrToSet( “[DimLearnerAgeBand]。[AgeBand]。[全部]”,约束),     StrToSet( “[DimLearningCourseLength]。[CourseLength]。[全部]”,约束),     StrToSet( “[DimLearnerEthnicity] [种族]。[全部]”,约束),     StrToSet( “[DimLearnerGender] [性别]。[全部]”,约束),     StrToSet( “[DimDeprivationDecile] [十分位数]。[全部]”,约束),     StrToSet( “[DimSectorSubjectArea] [Estyn]&安培; [2]”,约束),     StrToSet( “[DimLearningActivityLevel]。[ActivityLevel]。[全部]”,约束),     StrToSet( “[DimLearningActivityType]。[ActivityType]。[全部]”,约束)   )CELL PROPERTIES VALUE,BACK_COLOR,FORE_COLOR,FORMATTED_VALUE   ,FORMAT_STRING,FONT_NAME,FONT_SIZE,FONT_FLAGS