SSRS MDX数据集需要动态字段源,是否有解决方法?

时间:2014-11-21 10:37:04

标签: dynamic reporting-services dataset field mdx

我有一个以下工作MDX查询。问题在于TOPCOUNT,我使用case语句来计算我正在计算的内容。

投资者,顾问和ADVISERGROUP实际上都是与事实表中不同字段相关联的维度,即对于顾问,它将是Entity.IDKey - > Fact.AdviserKey或投资者的Entity.IDKey - > Fact.InvestorKey

所以问题是所有都会返回相同的字段名称,[ID KEY]但是会有不同的位置,即数据集字段源定义需要不同。

在SSRS中,它只适用于一个案例,它是在设计时运行的案例,并且对其他案例返回不正确。 有没有办法解决这个问题?

WITH MEMBER [Measures].[Previous Period] as
(   [Measures].[Fact TOL Activity Count] ,  
ParallelPeriod(
        IIF(@GroupBy = 'Y',   [Date].[Fiscal].[Fiscal Year],IIF(@GroupBy = 'Q' ,  [Date].[Fiscal].[Fiscal Quarter], [Date].[Fiscal].[Fiscal Month]))  
    , 1 
    ,[Date].[Fiscal].CurrentMember ))


MEMBER [Measures].[Current Period] as [Measures].[Fact TOL Activity Count] 

MEMBER [Measures].[CPeriod] as [Date].[Fiscal].CurrentMember.Name

MEMBER [Measures].[PPeriod] as 
ParallelPeriod(
      IIF( @GroupBy = 'Y',   [Date].[Fiscal].[Fiscal Year], IIF(  @GroupBy = 'Q' ,  [Date].[Fiscal].[Fiscal Quarter], [Date].[Fiscal].[Fiscal Month]))
    , 1 
    ,[Date].[Fiscal].CurrentMember ).Name

MEMBER [Measures].[Growth] as 

IIF (ISEMPTY([Measures].[Previous Period]), 0 , 
[Measures].[Fact TOL Activity Count]/ [Measures].[Previous Period] ), FORMAT = "Percent"


SELECT
{   
     [Measures].[Previous Period], [Measures].[Current Period],  [Measures].[Growth], [Measures].[PPeriod],[Measures].[CPeriod]

} ON COLUMNS,


(  TopCount(
    Except({

    CASE  [Dim User Type].[User Type Key].CurrentMember.NAME  
            WHEN "Adviser" THEN  [ADVISER].[ID Key].children 
            WHEN "Firm" THEN  [ADVISERGROUP].[ID Key].children
            WHEN "Investor" THEN [INVESTOR].[ID Key].children
            ELSE [INVESTMENTMANAGER].[ID Key].children 
    END

    } ,  

    CASE  [Dim User Type].[User Type Key].CurrentMember.NAME  
            WHEN "Adviser" THEN  [ADVISER].[ID Key].[Unknown]
            WHEN "Firm" THEN  [ADVISERGROUP].[ID Key].[Unknown]
            WHEN "Investor" THEN [INVESTOR].[ID Key].[Unknown]
            ELSE [INVESTMENTMANAGER].[ID Key].[Unknown]
    END
)

, 10
, (   [Measures].[Growth],  STRTOMEMBER(@CurrentPeriod, CONSTRAINED), [Dim EVENTTYPE].[IASEVENTTYPEKEY].&[ET00000040], STRTOMEMBER(@UserTypeKey, CONSTRAINED))
   )) on rows


FROM  [TOL Metrics Usage]

where  ( [Dim EVENTTYPE].[IASEVENTTYPEKEY].&[ET00000040],  STRTOMEMBER(@UserTypeKey, CONSTRAINED), STRTOMEMBER(@CurrentPeriod, CONSTRAINED) )

1 个答案:

答案 0 :(得分:0)

您有@UserTypeKey作为参数。因此,您可以根据此参数将您的定位基于报告。

如果要根据名称进行过滤,并且不想仅为名称创建另一个数据集,还可以添加另一个计算成员。

MEMBER [Measures].[UserTypeKeyName] AS [Dim User Type].[User Type Key].CurrentMember.NAME