1

SQL Server 2008 SSAS キューブで 3 つの計算メンバーが定義されています。

CALCULATE;         
/* Calculate Sales Volume */
CREATE MEMBER CURRENTCUBE.[Measures].[Ship Volume]
 AS [Measures].[QTY SHIPPED] + [Measures].[QTY ADJUST], 
FORMAT_STRING = "Standard", 
NON_EMPTY_BEHAVIOR = { [QTY SHIPPED], [QTY ADJUST] }, 
VISIBLE = 1 ,  DISPLAY_FOLDER = 'Calculated Members' ,  ASSOCIATED_MEASURE_GROUP = 'Sales';       
CREATE MEMBER CURRENTCUBE.[Measures].[Avg Price USD]
 AS [Measures].[NET SALES] / [Measures].[SHIP VOLUME], 
FORMAT_STRING = "Standard", 
VISIBLE = 1 ,  DISPLAY_FOLDER = 'Calculated Members' ,  ASSOCIATED_MEASURE_GROUP = 'Sales'  ;    
CREATE MEMBER CURRENTCUBE.[Measures].[Avg Price CAD]
 AS [Measures].[NET SALES CAD] / [Measures].[SHIP VOLUME], 
FORMAT_STRING = "Standard", 
VISIBLE = 1 ,  DISPLAY_FOLDER = 'Calculated Members' ,  ASSOCIATED_MEASURE_GROUP = 'Sales'  ; 

構文は正常に機能しますが、Excel でキューブを見ると、一部の値に #NUM! が含まれています。値として..これがなぜなのかわかりませんか?これはゼロ除算の問題によるものですか? これを回避するにはどうすればよいですか?

4

1 に答える 1

2

多分チェックします-等しくないA/B = C場合Bは 0 ですか?:

CALCULATE;         
/* Calculate Sales Volume */
CREATE MEMBER CURRENTCUBE.[Measures].[Ship Volume]
 AS [Measures].[QTY SHIPPED] + [Measures].[QTY ADJUST], 
FORMAT_STRING = "Standard", 
NON_EMPTY_BEHAVIOR = { [QTY SHIPPED], [QTY ADJUST] }, 
VISIBLE = 1 ,  DISPLAY_FOLDER = 'Calculated Members' ,  ASSOCIATED_MEASURE_GROUP = 'Sales';       
CREATE MEMBER CURRENTCUBE.[Measures].[Avg Price USD]
 AS Case
    When IsEmpty([Measures].[SHIP VOLUME] )
    THEN 0
    ELSE [Measures].[NET SALES] / [Measures].[SHIP VOLUME] END, 
FORMAT_STRING = "Standard", 
VISIBLE = 1 ,  DISPLAY_FOLDER = 'Calculated Members' ,  ASSOCIATED_MEASURE_GROUP = 'Sales'  ;    
CREATE MEMBER CURRENTCUBE.[Measures].[Avg Price CAD]
 AS Case
    When IsEmpty([Measures].[SHIP VOLUME] )
    THEN 0
    ELSE [Measures].[NET SALES CAD] / [Measures].[SHIP VOLUME] END, 
FORMAT_STRING = "Standard", 
VISIBLE = 1 ,  DISPLAY_FOLDER = 'Calculated Members' ,  ASSOCIATED_MEASURE_GROUP = 'Sales'  ; 

また、変更を試すこともできますIsEmpty([Measures].[SHIP VOLUME] )

[Measures].[SHIP VOLUME]=0

編集

IsEmpty([Measures].[SHIP VOLUME] )これを次のように変更してみてください

[Measures].[SHIP VOLUME] is null OR [Measures].[SHIP VOLUME]=0

于 2013-03-14T19:00:09.353 に答える