dcodling Posted April 12, 2010 Share Posted April 12, 2010 I need the syntax for a formula with in a variable expression that tests for two main condtions and each main condition has sub condtions.// if sold_to = 'Partner 1' then// if ((qs = 0) or (qd = 0) or ((100 * qs / qd) > 100)) then 0 else (100 * qs / qd)// else if sold_to = 'Partner 2' then// if ((qs = 0) and (kw = 0)) then category value// else if (kw = 0) then 0 else (qs / kw * 100)below code assigns 100 if not partner 1 or 2 instead of testing if KW = 0Code:$F{SOLD_TO}.equals("Partner 1") ? ($V{EofW_QS}.floatValue() == 0 || $V{EofW_QD}.floatValue() == 0 || (100*$V{EofW_QS}.floatValue())/$V{EofW_QD}.floatValue() > 100) ? new Double(100) : new Double(100.0*$V{EofW_QS}.floatValue()/$V{EofW_QD}.floatValue()): $F{SOLD_TO}.equals("Partner 2") ? ($V{EofW_QS}.floatValue() == 0 && $V{EofW_QW}.floatValue() == 0) ? new Double(100) : $V{EofW_KW}.floatValue()==0 ? new Double(0) : new Double($V{EofW_QS}.floatValue() / $V{EofW_KW}.floatValue() * 100): new Double(100) Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted April 12, 2010 Share Posted April 12, 2010 The base syntax is:(condition) ? (exp on true) : (exp on false)exp on true or false can be another similar expression.I.e:($F{Col} == 1) ? "red" : ( ($F{Col} == 2) ? "green" : ( ($F{Col} == 3) ? "blue" : "white" ) )Pay attention to the parenthesis...GiulioPost Edited by giulio at 04/12/2010 23:35 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now