Hi,
I have a requirement to calculate a running value against a non-time dimension. However, the dimension does not need to be ordered by a dimension but should aggregate based on the ordinal ranking of the dimension.
In order to do this I have used the SUM function with the RANK function and the HEAD function.
My MDX is below:
WITH MEMBER [Measures].[Non Empty Measure Rank] AS Rank([Months Since Take On].[MST Label].currentmember, {[Months Since Take On].[MST Label].[MST Label]}, [Measures].[Recovered Amount]) MEMBER [Measures].[MAX Non Empty Measure Rank] AS MAX([Months Since Take On].[MST Label].[MST Label],[Measures].[Non Empty Measure Rank]) MEMBER [Measures].[Ordinal Rank] AS Rank([Months Since Take On].[MST Label].currentmember, {[Months Since Take On].[MST Label].[MST Label]}) MEMBER [Measures].[Ordinal Rank Running Total] AS sum ( head( Order( [Months Since Take On].[MST Label].[MST Label],[Measures].[Ordinal Rank],ASC), iif([Measures].[Ordinal Rank] <= [Measures].[MAX Non Empty Measure Rank], [Measures].[Ordinal Rank], NULL) ) , [Measures].[Recovered Amount] ) SELECT NON EMPTY { [Measures].[MAX Non Empty Measure Rank], [Measures].[Ordinal Rank], [Measures].[Non Empty Measure Rank], [Measures].[Ordinal Rank Running Total], [Measures].[Recovered Amount], } ON COLUMNS, NON EMPTY { ([Months Since Take On].[MST Label].[MST Label].ALLMEMBERS * [Instruction Date].[Year Month].[Year Month]) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Quantum] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
When I specify a [Year Month] the query takes 7 seconds to execute. However, when I ask for all [Year Month]'s the performance of the query suffers greatly - 5+ minutes. When I attempt to run the query in BIDS the query timesout after circa 17 minutes with amessage stating that the operation was cancelled. (There is existing data for the Year Month's from 201010 to present)
The [Instruction Date].[Year Month].[Year Month] dimension begins at 200001 through to 201912.
The Months Since Take On dimension has labels from Month 0 to Month 250.
When running the query in MDX Studio I received a message stating that using the HEAD function within an aggregate function would disable subspace computation mode. Hence, I believe that the calculated measures are being evaluated in cell by cell mode which is obviously affecting performance.
Does anyone know how I can improve performance?
Or does anyone have a better way of writing the MDX in order to achieve what is needed?
Thanks in advance
Carl