Report variables allow you to define calculations to be performed for every record. This can be used, for example, for running totals.

By default, Stonefield Query creates one variable for each grouped field, named Report_GroupCount1, Report_GroupCount2, and so forth. These variables are used to count the number of records in each group and are displayed in the appropriate Group Footer bands.

To define or edit a variable, choose the Variables function in the Report menu.

The following options are available for variables:

  • Variables: this list shows the variables defined for the report. To select a variable for editing or removing, click its name in the list. Variables are evaluated in the order they appear in the list. This is normally only important if one variable references another variable in its Value to store or Initial value settings. To change the order, click the button in front of the variable to move and drag the button up or down in the list.

  • Add: click this button to add a variable. You're prompted for a name. Variable names must start with a letter and contain only letters, numbers, and underscores (that is, no spaces or punctuation).

  • Remove: click this button to remove the selected variable.

  • Value to store: the value or calculation to store to the variable for every record. It could be the name of a field, a constant value (such as 1), or an expression. Click the Expression Builder button to display the Expression Builder as an easier way to enter an expression.

  • Initial value: the variable's value before any calculations are performed, and the value to which the variable is reset. This defaults to 0. Click the Expression Builder button to display the Expression Builder as an easier way to enter an expression.

  • Reset value based on: allows you to specify the point at which the variable is reset to its initial value. By default, Report is displayed in the list box, meaning the variable retains its value until the end of the report. You can also select Page or Column, indicating that the variable is reset at the end of each page or column. If there are any groups in the report, this option displays an item for each group. If the report has more than one detail band, this option displays an item for each band.

  • Calculation type: this option allows you to specify a calculation that the variable performs. The variable begins calculating with its initial value, and continues until it is reset to this initial value. The choices are:

    • None: no calculations are made on this variable.

    • Count: counts the number of times a variable is printed per group, page, column, or report (depending on your selection in the Reset list). The calculation is based on the number of times the variable occurs, not on the variable's value.

    • Sum: computes the sum of the variable's values. This option keeps a running total of the values for a group, page, column, or report (depending on your selection in the Reset box).

    • Average: computes the arithmetic mean (average) of the variable values within a group, page, column, or report (depending on your selection in the Reset box).

    • Lowest: determines the lowest value that occurred in the variable for a group, page, column, or report (depending on your selection in the Reset list).

    • Highest: determines the highest value that occurred in the variable for a group, page, column, or report (depending on your selection in the Reset box).

    • Standard deviation: returns the square root of the variance for the variable values within a group, page, column, or report (depending on your selection in the Reset box).

    • Variance: measures the degree to which individual variable values vary from the average of all the values in the group, page, column, or report (depending on your selection in the Reset box).

  • Release after report: specifies that the variable is released after the report has run. This should normally be turned on, but can be turned off if you want to use the value of the variable in AfterRun code.


© Stonefield Software Inc., 2023 • Updated: 03/21/18
Comment or report problem with topic