Jump to content
We've recently updated our Privacy Statement, available here ×

Nested IF expressions


marlin_snyder

Recommended Posts

I have a Nested IF expression working in Crystal Reports:

 

if {@%Effect} <= 0 then
    {@CoCalcPL}
else if {@%Effect} < 80 then
    {@CoCalcPL} * (1 - ({@%Effect}/100))
else if {@%Effect} < 120 then
    0
else if {@%Effect} > 120 then
    ({@CashGL} * 1.2) - ({@CoCalcPL} * -1)
else 
    0

I'm struggling getting it to work properly in iReport:

$V{PctEffect} < 0.0 ? 0.0 :
    $V{PctEffect} < .8 ? $V{CoCalcPL}*(1.0-$V{PctEffect}) :
        $V{PctEffect} < 1.2 ? 0.0 :
            $V{PctEffect} > 1.2 ? ($V{CashGL}*1.2)-($V{CoCalcPL}*-1.0) :
            0.0

 

If I remove any two of the nested expressions, it will work fine, but when I add back even one nested expression,  I get a compile error before the report even begins to fill.  I have looked at several examples of nested IF expressions online and tried all of the various recommendations for enclosing in parenthesis, and haven't found anything to work with more than two expressions.

I'll post the xml below

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...