Quantcast
Channel: SQLServerCentral » Data Warehousing » Analysis Services » Latest topics
Viewing all articles
Browse latest Browse all 1341

Need help to improve mdx query

$
0
0
i got a query which brings me the top/bottom count of an intersection of 3 Dims.i need help in order to optimize this query since while i run it ,it takes like 20 minuets to run...here is the code:[quote]WITH MEMBER [Measures].[ActionActual] AS IIF([Measures].[Report_Measure] = NULL ,0,[Measures].[Report_Measure]) MEMBER [Measures].[ActionTarget] AS IIF([Measures].[Target]=NULL,0,[Measures].[Target]) MEMBER [Measures].[Gap] AS [Measures].[Target]-[Measures].[ActionActual] MEMBER [Direct] AS [DimMeasures].[Hierarchy].currentmember.properties( "Direction" ) MEMBER [Measures].[Count] AS [Org Struct].[Hierarchy].[Code].&[15].CHILDREN.COUNT SET PrmProvider AS CASE WHEN [DIM1].[Id].[All].children.count>0 THEN [DIM1].[Id].[All].children ELSE [DIM1].[Id].[All] END SET PrmProc AS CASE WHEN [DIM2].[Key].[All].children.count>0 THEN [DIM2].[Key].[All].children ELSE [DIM2].[Key].[All] ENDSET proc AS CASE WHEN [Direct]= "1.00" THEN CASE WHEN [Measures].[Count] >0 THEN TOPCOUNT((PrmProc,[Org Struct].[Hierarchy].[Code].&[15].CHILDREN,PrmProvider),20, [Measures].[Gap]) ELSE TOPCOUNT((PrmProc,[Org Struct].[Hierarchy].[Code].&[15],PrmProvider),20,[Measures].[Gap]) END ELSE CASE WHEN [Measures].[Count] >0 THEN BOTTOMCOUNT((PrmProc,[Org Struct].[Hierarchy].[Code].&[15].CHILDREN,PrmProvider),20,[Measures].[Gap]) ELSE BOTTOMCOUNT((PrmProc,[Org Struct].[Hierarchy].[Code].&[15],PrmProvider),20,[Measures].[Gap]) END END SELECT {[Measures].[ActionActual],[Measures].[ActionTarget],[Measures].[Gap]} ON COLUMNS , proc ON ROWS FROM [Opisoft Care DWH] WHERE ([Times].[Hierarchy].[Quarter Key].&[2009Q2],[DIM3].[Key].[All],[DimMeasures]. [Hierarchy].[Kpi Code].&[13]) [/quote]thank you

Viewing all articles
Browse latest Browse all 1341

Trending Articles