AMT Help Files

AVERAGE (AVG) (MEAN)

Syntax Color Legend
Command
Mandatory parameter
Optional parameter
Mandatory keyword
Optional keyword

Syntax

AVERAGE (<Source>, <Result>)

Description

When this command is used in conjunction with LEVEL_BREAK inside a loop, readfile loop, or query loop, the average of the source values between two level breaks is calculated and copied to the result variable.

Diagram

AVERAGE command diagram showing source values aggregated between level breaks and copied to a result variable.

Returned value type

None

Parameters

Parameter Description
Source The name of the variable to calculate the average of.
Result The name of the object to place the resulting average in.

Remarks

AVERAGE works only in conjunction with the LEVEL_BREAK command inside a readfile loop or query loop.

Example

readfile (lbfile, rec_lbf)
  lay_emp.dept   := rec_lbf.dept
  lay_emp.empnr  := rec_lbf.empnr
  lay_emp.salary := rec_lbf.salary
  lay_hdr.hdept  := rec_lbf.dept

  level_break (rec_lbf.dept, lay_ftr, lay_hdr, 3)
  average (rec_lbf.salary, lay_ftr.avgsal)
  maximum (rec_lbf.empnr, lay_ftr.maxemp)
  variance (rec_lbf.salary, lay_ftr.varsal)
  print (lay_emp)
endread

Return to

Commands

Contents