2015-05-28 54 views
-1

的MDX Qyery工作正常,爲一年的表現,我們怎麼可以運行相同的查詢,兩年來性能的MDX Qyery做工精細的一年,我們如何可以運行相同的查詢,兩年來

WITH 

MEMBER [Measures].[Metric] AS Round(sum(({[Year].[Year].&[2015]}),[Measures].[PurchaseSum]),2) 
SET CustYear as exists([DIMCustomer].[Level 02].allmembers,({[Year].[Year].&[2015]}),"sales")    
    SET [BusinessSet] AS { filter(( 
       EXISTS(CustYear, [DIMCustomer].[HierarchyCategory].&[UnitHierarchy],"sales") 
    ),([Measures].[Metric] or [Measures].[Metric]=0))} 

    SET [SellerFilterCustomerID] AS EXISTS([DIMSeller].[CustId].ALLMEMBERS,{[DIMSeller].[CustId].[All]}, "sales") 
    SET [SellerFilterCustomerType] AS EXISTS([DIMSeller].[CustId].ALLMEMBERS,[DIMSeller].[CustomerType].[All]) 
    SET [SellerFilterCompanyName] AS EXISTS([DIMSeller].[CustId].ALLMEMBERS,{[DIMSeller].[Name].[All]}, "sales") 
    SET [SellerFilterCompanyLoc] AS EXISTS([DIMSeller].[CustId].ALLMEMBERS,[DIMSeller].[Organization].[All]) 
    SET [FinalSellerFilter] as (intersect(intersect(intersect([SellerFilterCustomerID],[SellerFilterCustomerType]),[SellerFilterCompanyName]),[SellerFilterCompanyLoc])) 
    SET Name  AS {[DIMCustomer].[Name].[All]} 
    SET Code AS {[DIMCustomer].[Code].[All]} 
    SET CustType AS {[DIMCustomer].[CustomerType].[All]} 
    SET OrgLoc  AS {[DIMCustomer].[Organization].[All]} 
    SET CustFilters AS (Name,Code,CustType,OrgLoc)  
    SET ICP as {{[DimProduct].[ICP].[All]}} 
    SET ProdICP as (ICP) 

    //creating year filter 
    SET CrYear as {[Year].[Year].&[2015]} 


    SET Others AS (CrYear,ProdICP) 
    SET [SalesSet] AS exists([BusinessSet],[FinalSellerFilter],"sales") 
    //creating final set 
    SET FINALSET as exists([SalesSet],CustFilters,"sales") 
    SET Geo as exists([DIMCustomer].[ParentPostalNumber].[ParentPostalNumber],({[Year].[Year].&[2015]}),"sales") 
    SET [FIPS] AS Except(EXISTS(Geo,[SalesSet], "sales"),{[DIMCustomer].[ParentPostalNumber].&[0],[DIMCustomer].[ParentPostalNumber].&[]}) 

    MEMBER [Measures].[Sales] AS round(sum(([FINALSET],Others),[Measures].[Metric]),2) 

    MEMBER [Measures].[Count] as (exists(([FINALSET],Others,[SalesType].[SalesType].&[3]),[DIMCustomer].[ParentPostalNumber].currentmember, "sales")).count 
SELECT 
non empty { 
[Measures].[Sales],[Measures].[Count] 
    } ON 0, 
    NON EMPTY{ 
    FIPS 
    } ON 1 
FROM [cube]** 
+0

我們確實需要更全面的解釋。 – whytheq

+0

這是ONE BIG MESSED UP查詢!幾件事情。 1.儘可能避免命名集。嘗試推算計算以創建'MEMBER'。 2.儘可能嘗試使用「NonEmpty」。 3.除非確實需要,否則請儘量避免使用「非空」。 4.擺脫腳本中最終查詢中未使用的集合。我還無法理解「EXISTS([DIMSeller]。[CustId] .ALLMEMBERS,{[DIMSeller]。[Name]。[All]},」sales「)''背後的原因。你爲什麼要這樣做? – SouravA

回答

0

運行這2年只是交換的這一切實例:

{[Year].[Year].&[2015]} 

這個...

{[Year].[Year].&[2014], [Year].[Year].&[2015]} 

分區中您的倉庫很可能是原因 - Exists函數返回到事實表。雖然也許你能避免這種情況下的使用Exists和尋找替代:

EXISTS([DIMSeller].[CustId].ALLMEMBERS,{[DIMSeller].[CustId].[All]}, "sales") 

Sourav已經注意到,您可能會使用EXISTS代替NonEmpty - 如果你能使用後的功能,因爲它是更有效的。

+0

alerady我測試它會在20分鐘內運行。這是個問題。 – user3843858

+0

,但只運行一年它很快運行? – whytheq

+0

仍然無法正常工作,我正在刪除存在和分區。 – user3843858

相關問題