Posted: 10/11/2011
Hi,
I am new to any complex or involved MDX code. I am stuck and I need to get this done. Would really appreciate your help.
I am trying to create a calculated member for percentile and I found the approach in the following link
http://www.bidn.com/articles/mdx-and-dmx/6/calculating-percentile-in-sql-server-analysis-services-mdx
The data returned by the cube is accessed by a third party visualization tool. I am not looking for an MDX query. I need the percentile to be a measure returned for the current cube (after filters and groupings are applied). Do you have any solutions/any approach for creating percentile dynamically as a calculated memberfor the CURRENTCUBE?
Here is what I have:
CREATE MEMBER CURRENTCUBE.[Measures].SurveyMean AS ( [Measures].[Weigthed Total] , [Survey Table-Id only].[Survey ID]) / ([Measures].[User Count],[Survey Table-Id only].[Survey ID]), FORMAT_STRING = "Standard", VISIBLE = 1 , ASSOCIATED_MEASURE_GROUP = 'Dundas Survey Response Scores Non Check Box'; CREATE DYNAMIC SET CURRENTCUBE.[SurveyMeanRankSet] AS ORDER([Survey Table-Id only].CHILDREN, [Measures].[SurveyMean],DESC) ; CREATE MEMBER CURRENTCUBE.[Measures].[SurveyMeanRank] AS Null, FORMAT_STRING = "Standard", VISIBLE = 1 , ASSOCIATED_MEASURE_GROUP = 'Dundas Survey Response Scores Non Check Box'; CREATE MEMBER CURRENTCUBE.[Measures].[SurveyCount] AS COUNT(NONEMPTY([Survey Table-Id only].[Survey ID].Members)), FORMAT_STRING = "Standard", VISIBLE = 1 , ASSOCIATED_MEASURE_GROUP = 'Dundas Survey Response Scores Non Check Box' ; SCOPE ([Measures].[SurveyMeanRank],[Survey Table-Id only].[Survey ID]); THIS=RANK([Survey Table-Id only].CurrentMember, [SurveyMeanRankSet]); END SCOPE;
If I get the SurveyMeanRank calculate correctly then I can get the percentile calculated.
When I drag [Survey ID] to the row area: SurveyCount in column area works and returns the correct count (obviously same value for all), SurveyMean in column also calculate correctly; However, SurveyMeanRank dragged to the column area shows null for all [survey id] and shows 0.0 for the Grand Total.
If I add MEMBERS to the scope statement (see below in bold)
SCOPE ([Measures].[SurveyMeanRank],[Survey Table-Id only].[Survey ID].MEMBERS); THIS=RANK([Survey Table-Id only].CurrentMember, [SurveyMeanRankSet]); //THIS = 2; END SCOPE;
it would make the scope work for a simple THIS=2; [SurveyMeanRank] for all [survey Id]s returns as 2; However, when MEMBERS is added tot he SCOPE statment (in bold) with the rank statement (THIS=RANK....) the browser returns the error "could not evaluate dynamic set SurveyMeanRankSet in current scope."
What should I change to have the rank calculated correctly?
Any suggestion for calculating percentile using this approach or any other approach?
really appreciate your help.