Pregunta

I am trying to calculate a new measure with certain conditions, I've created a first level member first and then tried to use that in next member definition.

The next member "CashDisp" is evaluating to Zero with If condition, I am new to SSAS please help me to fix this

/*
The CALCULATE command controls the aggregation of leaf cells in the cube.
If the CALCULATE command is deleted or modified, the data within the cube is affected.
You should edit this command only if you manually specify how the cube is aggregated.
*/
CALCULATE;    
CREATE MEMBER CURRENTCUBE.[Measures].CashDispensed
 AS [Measures].[Orig Trans Amount]/100, 
VISIBLE = 1;     
CREATE MEMBER CURRENTCUBE.[Measures].CashDisp
 AS IIF([Dim Trans Type Code].[Trans Type Code] ='10'
and [Dim Termn Ln].[Termn Ln]= 'PRO1'
and [Dim Reversal Reason].[Reversal Reason] ='00'
and [Dim Trans Response Code].[Trans Response Code] ='051',[Measures].CashDispensed,0), 
VISIBLE = 1  ; 
¿Fue útil?

Solución

The problem is how you are comparing the Dimension values.

When you say

[Dim Trans Type Code].[Trans Type Code] ='10'

that is really comparing

[Dim Trans Type Code].[Trans Type Code].[All] to '10'.

You need to write your comparison like this:

IIF([Dim Trans Type Code].[Trans Type Code].currentmember IS [Dim Trans Type Code].[Trans Type Code].&[10],[Measures].CashDispensed,0)

That exampled is condensed but you can see the change for each dimension. This also requires that each dimension hierarchy is somewhere in your query. If not, then it's the All version of it and your IIF will not evaluate to the member you created.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top