Expressions The scripting language in Jasper's reports is your friend!
What I can understand from your query is that you want to calculate the value of a variable based on the values โโof two parameters. In short, you want to do something like: -
Simple if-else
If (branchId == 1 && spType == "abc") branchName = "Xyz1"; else branchName = "Xyz2";
In the Jasper scripting language, the specified expression can be written as: -
($P{branchId}==1 && $P{spType} != null && $P{spType}.equals("abc"))?"Xyz1":"Xyz2"
Nested If-else
If (branchId == 1 && spType == "abc") branchName = "Xyz1"; else if (branchId = 2 && spType == "def") branchName = "Xyz2"; else branchName = "Xyz3";
Expression of expression:
( $P{branchId} ==1 && $P{spType} !=null && $P{spType}.equals("abc") ) ? "Xyz1" : (($P{branchId} == 2 && $P{spType} != null && $P{spType}.equals("def")) ? "Xyz2" : "Xyz3");
See this lesson for more details: http://www.tutorialspoint.com/jasper_reports/jasper_report_expression.htm
Here is a similar stackoverflow question as well: do a comparison if else in JasperReports
For the basic concept, page number. 10 of this pdf: http://jasperreports.sourceforge.net/JasperReports-Ultimate-Guide-3.pdf
source share