2017-05-17 93 views
0

想象一個尺寸爲 - DimA,DimB,DimC和DimD的立方體。SSAS MDX計算的成員,多個示波器

我想要一個計算的成員,只應該根據DimA或DimB切片來計算。如果僅針對DimC或DimD進行切片,則應該返回Null。

目前我已經實現了這一點,通過下面的3個計算成員:

Create Member CurrentCube.[Measures].[CalMeasure1] As Null, VISIBLE = 0; 

SCOPE([Measures].[CalcMeasure1]); 
     SCOPE ([DimA].[DimA].[DimA]); 
      This = [Measures].[Camp Index]; 
     END SCOPE; 
END SCOPE; 


Create Member CurrentCube.[Measures].[CalcMeasure2] As Null, VISIBLE = 0; 

SCOPE([Measures].[CalcMeasure2]); 
     SCOPE ([DimB].[DimB].[DimB]); 
      This = [Measures].[Camp Index]; 

CREATE MEMBER CURRENTCUBE.[Measures].[CalcMeasure3] 
AS IIF(ISEMPTY([Measures].[CalcMeasure1]),[Measures].[CalcMeasure2],[Measures].[CalcMeasure1]), 
VISIBLE = 1 ; 
     END SCOPE; 
END SCOPE; 

我要創造不少的這些,所以理想情況下,我想用一個單一的措施來做到這一點,而不是3個獨立的措施。我曾嘗試創建一個嵌套的作用域。我也嘗試將兩個維度層次結構放在一個範圍內。但是,這些方法都不起作用。兩種方法都要求將度量與DimA和DimB進行切片。如果對DimA或DimB進行切片,我需要它工作。

注意我上面的代碼不工作,我只是想濃縮成一個單一的計算成員

編輯: -預期結果,針對不同的數據透視表的用途。

DimA Attribute CalcMeasure3 
1     1.1 
2     1.1 
3     8.6 


DimB Attribute CalcMeasure3 
4     2.1 
5     2.1 
6     9.6 


DimA Attribute DimC Attribute CalcMeasure3 
1     A     1.1 
2     B     1.1 
3     C     8.6 


DimB Attribute DimD Attribute CalcMeasure3 
4     D     1.1 
5     E     1.1 
6     F     8.6 

DimC Attribute CalcMeasure3 
A     (Null) 
B     (Null) 
C     (Null) 


DimD Attribute CalcMeasure3 
D     (Null) 
E     (Null) 
F     (Null) 

回答

1

這個怎麼樣計算的措施,而不適用範圍:

WITH MEMBER [Camp Index] AS 
IIF( 
    not ([DimA].[DimA].CurrentMember is [DimA].[DimA].[All]) or not([DimB].[DimB].CurrentMember is [DimB].[DimB].[All]), 
[You Calcuate], 
IIF( 
    not ([DimC].[DimC].CurrentMember is [DimC].[DimC].[All]) or not([DimD].[DimD].CurrentMember is [DimD].[DimD].[All]), 
    NULL, 
    [You Calcuate] 
), 
NULL 
) 
SELECT 
{[Camp Index]} on 0 
from [Adventure Works] 
+0

(提高)謝謝貢獻Tom – whytheq

0

我的第一個猜想:

Scope([Measures].[Camp Index]); 
    This = IIF(
       [DimC].[DimC].[DimC].CurrentMember is [DimC].[DimC].[All] 
       and 
       [DimD].[DimD].[DimD].CurrentMember is [DimD].[DimD].[All] 
       [Measures].[Camp Index], 
       NULL 
    ); 
End Scope; 
+0

謝謝。 [DimA]。[DimA]。[DimA] .CurrentMember是[DimA]。[DimA]。[All]和[DimB]。[DimB]。[DimB] .CurrentMember是[DimB]。[DimB] 。[所有]?如果是這樣,那麼即使通過DimA,DimB或兩者切片,它總是返回null。由DimC,DimD或Dim(n) – user8025238