10 Replies Latest reply: Aug 5, 2013 10:21 AM by Daniel Kohler

# 2 times if

Hi all,

I have a really difficult problem:

I want to calculate in this way:

if column1 = A,B,C

and if (A=A(comlumn2);B=B (comlumn2);C=C(comlumn2) then Value(column3)*1; else do Value(column3)*1,1;)

if  column1 = D then  Value(column3)*1

So there are two if sentences.

Thank you for helping!

If you need a better explanation - just tell me! :-)

• ###### Re: 2 times if

Yes, please explain a bit better.

• ###### Re: 2 times if

Ok, here is my next try:

I have a table with one value and two columns of towns:

 Value Town1 Town2 Result i want 3 M M 3 4 FFM FFM 4 5 M FFM 1,1*5 6 M FFN 1,1*6 754 FFM M 1,1*754 3 FFM FFM 3 23 M FM 1,1*23 5 Berlin Berlin 5 Berlin is always *1 56 Berlin FFM 56 Berlin is always *1 6 M M 6

So If the Town1 and the Town 2 is not the same I want to multiply the value with 1,1 !

If it is the same i want the same value => multiply with 1.

Berlin should not be affectet and always be multiplied with 1

Hope that helps!

• ###### Re: 2 times if

try this

if(Town1=Town2 or Town1='Berlin',Value,11*Value)

• ###### Re: 2 times if

try this:

If( Town1='Berlin', Value, If(Town1=Town2, Value, Value * 1.1))

assuming '1,1' is your typing mistake and you meant '1.1'

• ###### Re: 2 times if

if you want to do nested if-Statements, here as a good tool:

http://www.qlikblog.at/tools/Nested-If-Generator.html

Hope this helps a little bit

• ###### Re: 2 times if

try like this way

if  column1 = D then  Value(column3)*1 else

if column1 = A,B,C

and if (A=A(comlumn2);B=B (comlumn2);C=C(comlumn2) then Value(column3)*1; else do Value(column3)*1,1;

• ###### Re: 2 times if

example of nested if--

if(Value='5',X,

if(Value='4',Y,

if([Indicator Number]='7' and Value='3',Z,

if(([Indicator Number]='8' or [Indicator Number]='9') and Value='2',ABC,

if(Value='1',A,

if(Value='2',P,Q))))))

• ###### Re: 2 times if

Ok, here is my next try to explain it:

I have a table with one value and two columns of towns:

 Value Town1 Town2 Result i want 3 M M 3 4 FFM FFM 4 5 M FFM 1,1*5 6 M FFN 1,1*6 754 FFM M 1,1*754 3 FFM FFM 3 23 M FM 1,1*23 5 Berlin Berlin 5 Berlin is always *1 56 Berlin FFM 56 Berlin is always *1 6 M M 6

So If the Town1 and the Town 2 is not the same I want to multiply the value with 1,1 !

If it is the same i want the same value => multiply with 1.

Berlin should not be affectet and always be multiplied with 1

Hope that helps!

• ###### Re: 2 times if

If(Town1 = 'Berlin', Value,

If(Town1 =Town2, Value, Value * 1.1))

• ###### Re: 2 times if

Maybe this:

Data:

If(Town1='Berlin' or Town2='Berlin' or Town1=Town2,Value,Value*1.1) as Result
;

Value, Town1, Town2
3, M, M
4, FFM, FFM
5, M, FFM
6, M, FFN
754, FFM, M
3, FFM, FFM
23, M, FM
5, Berlin, Berlin
56, Berlin, FFM
6, M, M
1000, x, Berlin
]
;