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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculated new field

I need to create a new field to indicate BUY, New BUY or Sell, New SELL depending on the fields ordtype and liq .
eg. if ordtype = 1 AND liq>0 then "buy" else if ordtype = 1 ANd liq = 0 then "new buy"if ordtype = 2 And liq >0 then = "sell" else if ordtype 2 ANd liq =0 then = "new sell ".
how do this during mapping?
Labels (2)
4 Replies
Anonymous
Not applicable
Author

Hi
The expression look like:
row1.ordtype==1&&row1.liq>0?"buy" Smiley Sadrow1.ordtype==1&&row1.liq==0?"new buy" Smiley Sadrow1.ordtype==2&&row1.liq>0?"sell":"new sell"))
Best regards
Shong
Anonymous
Not applicable
Author

oh i got this error Exception in thread "main" java.lang.Error: java.lang.Error: java.lang.Error: Unresolved compilation problems:
Incompatible operand types String and int
Incompatible operand types String and int
Incompatible operand types String and int

i think i because ordtyp is a string and liq is a int
alevy
Specialist
Specialist

Then modify shong's expression to:
row1.ordtype.equals("1")&&row1.liq>0?"buy" Smiley Sadrow1.ordtype.equals("1")&&row1.liq==0?"new buy" Smiley Sadrow1.ordtype.equals("2")&&row1.liq>0?"sell":"new sell"))
although I would use the expression:
(row1.liq==0?"new ":"")+(row1.ordtype.equals("1")?"buy":"sell")
Anonymous
Not applicable
Author

Hi alevy
although I would use the expression:
(row1.liq==0?"new ":"")+(row1.ordtype.equals("1")?"buy":"sell")

Good expression, it is short and simple.
Best regards
Shong