Table of Contents

Jasper Server and Reports

Variable Tricks

Goal Variable Class Calculation Example
All Rows Integer none
use built-in REPORT_COUNT
Specific Fields Integer Count
$F{Field}.contains("RegEx") ? 1 : null
Unique Fields Integer Distinct Count
$F{Field}
Multiple Conditions Integer Count
$F{Field1}.contains("RegEx") && $F{Field2}.matches("Const") ? 1 : null
Unique with Multiple Conditions Integer Distinct Count
($F{Field1} + $F{Field2}).endsWith("Const") ? $F{Field1} : null

Syntax - the '? TRUE : FALSE' conditional statement is shown above. What follows '?' is the output if the first statement is TRUE, if FALSE what follows : is the output.

Count All Rows - the built-in variable REPORT_COUNT is a count of all rows. If data in a column is guaranteed to be unique then this variable will equal the total count.

Specific Fields - the example shows how to use a regular expression to evaluate field contents. The count is incremented by one every time the regular expression finds a match.

Unique Fields - the Distinct Count function outputs the number of unique occurrences. Useful if your dataset has duplicate values.

Multiple Conditions - the example shows how to require both statements to be TRUE (via &&) in order to increment the counter.

Unique with Multiple Conditions - this example is a combination of the previous two. The important operator is that went TRUE the output is the Field that you want Distinct Count to evaluate.

Jasper Server Config

iReports Config

Server 500 error

/etc/init.d/jasperserver stop
rm -rf /opt/jasper/jasperserver/apache-tomcat/work/
/etc/init.d/jasperserver start

Jasper Server Install

iReports Install/Upgrade

ln -sf /opt/jasper/jasperserver/iReport-New_Ver /opt/jasper/jasperserver/ireport