Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

combine 4 if statements into a single expression. need help..pl???

hi all,

Please request help on the below issue.

I have 4 if statements below and  t,I am not able to resolve it,please can anyone help me out???

i AM NOT GOOD IN NESTED IF'S SO PLEASE CAN SOMEONE HELP ME WITH THIS????????????

1)if( market_value_1<= strike_price,-1*(premium),((-1*(premium)+ (market_value_1-strike_price))))  and  ([Buy/Sell]='BUY' AND xoptiontype='CALL'

2) if( market_value_1<= strike_price,+1*(premium),((+1*(premium)- (market_value_1-strike_price))))  and  ([Buy/Sell]='SELL' AND xoptiontype='CALL'

3)    if( market_value_1<= strike_price,((-1*(premium)+ (strike_price-market_value_1))),-1*(premium))  and  ([Buy/Sell]='BUY' AND xoptiontype='PUT'

  4)  if( market_value_1<= strike_price,((+1*(premium)- (strike_price-market_value_1))),+1*(premium))  and  ([Buy/Sell]='SELL' AND xoptiontype='PUT'

I HAVE ATTACHED THE FILE FOR REFERENCE.

In them the 4 columns buy_call,buy_put,sell_call and sell_put are differently displayed which needs to be combined to a single column with the extra contion for esch case:

([Buy/Sell]='BUY' AND xoptiontype='CALL'  etc.. as shown above.

11 Replies
Not applicable
Author

Hi Anbu

I will try to make it better for you ,probably my question was lil confusing to understand.

eg:

Condition 1

IF buy_sell = 'BUY' and xoptiontype_ = 'CALL' and market_value_1 <= strike_price

then it should show -1*(premium) else it should show its own else statement which is ((-1*(premium)+ (market_value_1-strike_price)) and then move to the next condition

the same thing for the rest of the conditions as well.

hence

buy/call

sell/call

buy/put

sell/put

should be iterated one after the other after it goes through its own conditions.

I wish this would explain my requirement better.

anbu1984
Master III
Master III

Try this and make sure to correct cases of buy_sell and xoptiontype_

=if( buy_sell = 'BUY' and xoptiontype_ = 'CALL', If(market_value_1 <= strike_price,-1*(premium),((-1*(premium)+ (market_value_1-strike_price))))

,if( buy_sell = 'sell ' and xoptiontype_ = 'call', If( market_value_1 <= strike_price,+1*(premium),((+1*(premium)- (market_value_1-strike_price))))

,if( buy_sell = 'buy ' and xoptiontype_ = 'put',

If(market_value_1 <= strike_price,((-1*(premium)+ (strike_price-market_value_1))),-1*(premium))

   ,if( buy_sell = 'sell ' and xoptiontype_ = 'put',

      If(market_value_1 <= strike_price,((+1*(premium)- (strike_price-market_value_1))),+1*(premium)) 

      ,0)

   ) 

))