A report can declare a number of variables. Variables represent named expressions
that are used to store some global objects or perform various calculations. Once
declared, they can be referred to in other expressions using a dedicated syntax.
JasperAssistant groups these declarations under a single Variables
node in the Outline View
. New variables can be added by using the
context menu associated to this node.
Variables can perform built-in types of calculations like: count, sum, average, lowest, highest, variance, etc.
For variables that perform calculations, a reset type can be specified. A reset type indicates the moment of report execution at which the variable is reinitialized. The default reset type is Report and it indicates that the variable is initialized only once at the beginning of the report, and that it performs the specified calculation until the end of the report is reached. Other reset types can be specified in order to perform calculations at page, column or group levels.
In its expression, a variable can reference other report variables, but only if those referenced variables were previously defined. This means that the order in which the variables are declared is important.
Variable Properties
Name
Name of the report variable as it is used to refer to the variable throughout the report.
Expression
Expression that determines the value that is used to perform calculations.
Value Class
Class of the variable values as obtained by evaluating the
Variable
's expression.
Initial Value Expression
Expression that determines the Variable
's initial
value.
Calculation
Specifies the calculation type to perform on the
Variable
's expression.
Nothing
- No calculation is performed.
Count
- The variable calculates the number of the
not null values obtained as the result of
Variable
's expression evaluation.
Distinct Count
- The variable calculates the number of the distinct
not null values obtained as the result of
Variable
's expression evaluation.
Sum
- The variable calculates the sum of the not
null values obtained as the result of Variable
's
expression evaluation. This type is only valid for numerical
variables.
Average
- The variable calculates the average of
the not null values obtained as the result of
Variable
's expression evaluation. This type is
only valid for numerical variables.
Lowest
- The variable calculates the lowest value
obtained as the result of Variable
's expression
evaluation.
Highest
- The variable calculates the highest
value obtained as the result of Variable
's
expression evaluation.
Standard Deviation
- The variable calculates the
standard deviation of the not null values obtained as the result of
Variable
's expression evaluation. This type
is only valid for numerical variables.
Variance
- The variable calculates the variance
of the not null values obtained as the result of
Variable
's expression evaluation. This type is
only valid for numerical variables.
System
- Custom calculation.
First
- The variable calculates the first
encountered value that is obtained as the result of
Variable
's expression evaluation. All the
subsequent values are ignored.
Reset Type
Indicates the moment of report execution at which the variable is reinitialized.
Report
- Variable is initialized once, at the
beginning of the report.
Page
- Variable is initialized at the beginning
of each page.
Column
- Variable is initialized at the beginning
of each column.
Group
- Variable is initialized each time the
group specified by the Reset Group
property
changes its value.
None
- Variable is never reinitialized.
Reset Group
Name of the group at which the variable is reinitialized, when the
Reset Type
property is set to
Group
.
Incrementer Factory Class
The name of a class that implements the
net.sf.jasperreports.engine.fill.JRIncrementerFactory
interface to use when creating the incrementer instance for this variable.
Incrementers are objects that implement the
net.sf.jasperreports.engine.fill.JRIncrementer
interface
and handle the incremental calculation performed on the variable's current value
with every iteration in the data source.
Increment Type
Indicates the moment of report execution at which the variable is incremented.
Report
- Variable is incremented only once, at
the end of the report.
Page
- Variable is incremented at the end of each
page.
Column
- Variable is incremented at the end of
each column.
Group
- Variable is incremented when the group
specified by the Increment Group
attribute
changes.
None
- Variable is incremented with every record
in the data source.
Increment Group
Name of the group at which the variable is incremented, when the
Increment Type
property is set to
Group
.