I have the following query that returns the results I need but wont work in 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) )
The problem is the TOPCOUNT on the rows. INVESTOR, ADVISER and ADVISERGROUP are all actually the same dimension linked to different fields in a fact Table, ie for Adviser it would be Entity.IDKey - > Fact.AdviserKey or for Investor its Entity.IDKey -> Fact.InvestorKey
So using a case statement I can retrieve the correct dimension based on user selection.
However I do not know how to get it to work in SSRS. The field source specifies the exact type and because the field name is the same for all, IDKey, I cannot manually add more field definitions.
Is there a way to dynamically change the Field Source or a better way to do this.
Thanks
Jon