Jump to content
Changes to the Jaspersoft community edition download ×

IF ELSE-IF ELSE-IF ELSE END IF / Switch Help please


sunnycappm

Recommended Posts

Im new to jaspersoft world and trying to write an expresion that evaluates the value of a text box 

IF 
        CP =1 AND TP = 1 Then "CT"
    ELSEIF 
        CP =1 THEN "C"
    ELSEIF 
        TP = 1 THEN "T"
    ELSE 
        ""
    END IF

I tried the following with not much success

IF ($F{CP} == 11 && $F{TP} == 1),"CT", IF ($F{CP} == 1),"C",IF ($F{TP} == 1),"T","" 

This works partially but it doesnt evalue the expression in the else part and expects a constant...and not one more expression to evaluate

(($F{CP} == 1)  &&  ($F{TP})== 1) ? "CT" : ($F{CP} == 1)? "C" : ($F{TP} == 1)? "T"

Any tips on writing expressions would help greatly...even if its your own cheatsheet?

  

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Thank you!

I figured out soon after my original post...;) Here it is for the benefit of others

($F{CP} == 1  && $F{TP}==11) ? "XT": 
$F{CP} == 1 ? "X": 
$F{TP}== 1 ? "T":""

Here's another example

$F{P} == 1 ? "1  -  10-19%": 
$F{P} == 2 ? "2  -  20-39%": 
$F{P} == 3 ? "3  -  40-59%": 
$F{P} == 4 ? "4  -  60-79%": 
$F{P} == 5 ? "5  -  80-100%": 
""

Hope that helps!

 

Link to comment
Share on other sites

  • 5 years later...

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...