2 Replies Latest reply on Jun 29, 2016 7:58 AM by Shinichiro Murakami

# IF and ELSE statement

Suppose I want to create a metric 'XYZ' which is to be used as a dimension based on some common key A. I am writing the statement:

if A='1' or A='2'

then 'X'

elseif A='1' or A='3'

then 'Y'

elseif A='2' or A='4'

then 'Z'

end

This statement is computing X for both A=1 and A=2. It is computing A=3 for Y but A=1 is not being computed.

For Z, only A=4 is getting computed.

Therefore, I want to perform an action where my X, Y and Z are calculated for their assigned values of A.

Please suggest some method which can be used.

Thanks

• ###### 1. Re: IF and ELSE statement

The formula will stop evaluating a value when it finds a match as true.

So if A=1, it will return 'X' and the next 'elseif' will never be evaluated.

Effectively, you cannot calculate A='1' as being both X and Y in the same dimension.

• ###### 2. Re: IF and ELSE statement

You can create three calculated fields to judge X,Y,Z instead.

[Judge X]

if [A]=1 or [A]=2 then "X" END

[Judge Y]

if [A]=1 or [A]=3 then "Y" END

[Judge Z]

if [A]=2 or [A]=4 then "Z" END

Thanks,

Shin

9.2 attached