Simplicty and flexibility!

# Function::Internal

Mean Of
mean of RELATIONSHIP colum
mean of TABLENAME column

Syntax:
mean of TABLENAME|RELATIONSHIP
[ named "UNIQUE RELATIONSHIP NAME" ]
[ with {selection criteria} ]
FIELDNAME

The mean of operator calculates the average value in a specified field in all matching records in a related table. The result can appear as a list item in the detail area of a report or as a statistic in the summary area at the end of each group or at the end of the report.

The mean of operator calculates the average value in a specified field in all matching records in a related table. The mean of operator calculates the average of all the values in the specified field (the sum of the values divided by the number of values processed). Blank fields are ignored. Fields that have a value of zero are included in the calculation.

There's an important difference between the statistical operator mean and the relational statistical operator mean of. mean finds the average value in the specified field among the records being processed. mean of finds the average value in the specified field among the records related to the records being processed.

# Parameters

TABLENAME

You can use Count of directly on a table without a predefined Relationship. Just remember that if there is a Relationship defined that doesn't have an alternative relationship name, this relationship will be named the same and the table and be used.

RELATIONSHIP

If you use a relationship (alternative name) then the count of will be automatically restricted by the relational restriction. Read under TABLENAME for functionality when using Relationships without alternative relational name.

NAMED "Unique Relationship Name"
You can define an ad hoc named relationship directly in the Count Of function. If you do this you will possibly achieve two things. 1) You will insure against DataEase using a pre-defined relationship with the same name as the table. 2) You can re-use it again in the same script i.e. on a Sum Of etc.
WITH {selection criteria}
With the WITH statement you define the relational restriction of the function. Ex. MyCustomerNR=CustomerNR and MyDate>current date.
FIELDNAME
Name of the Data Column/Field that is being summed up ex. InvoiceLineSum, NumberComplaints, InvoiceTotal

A numeric value.

# Examples

Example 1

In a field derivation.Simplest type. We have two tables. ThisTable and MyCustomers. We have no relationships defined.

highest of MyCustomers TotalInvoiced

This will return the highest invoiced Total  that I have invoiced all my customers.

Example 2

We have two tables.CustomerType and MyCustomers. We have a relationship betweenÂ them that connect CustomerType and MyCustomers on customer type.There is no Unique Alternative Name for the Relationship. I have 300 records in MyCustomer and 45 of type Good Credit. My best customer with Good Credit have been invoiced \$3200 and the best customer overall have been invoiced \$5000.

My active record in CustomerType is the Good Credit record.

highest of MyCustomers TotalInvoiced

This will return the number \$3200 as I am now using the relationship instead of the table.

highet of MyCustomers named "AllRecords"

This willÂ return the number \$5000 as I have now defined a unique relationship with no restriction and I will get the total invoiced across the table..

Example 3

highest of MyCustomers named "NewRel" with RegistrationDate=current date TotalInvoiced

Example

for MEMBERS ;

list records

LAST NAME in order ;

mean of RESERVATIONS TOTAL DUE .

end

This script tells DataEase: (1) Process all the MEMBERS records and list each member's LAST NAME in alphabetical order, (2)for each MEMBERS record processed, find all the related records in the RESERVATIONS table (those that have the same MEMBERID), and (3) list the mean TOTAL DUE for each member from the set of related RESERVATIONS records.

The output from this script might look as follows:

Last Name

Mean of Reservations Total Due

\$2780.00

Albert

\$4430.00

Anders

\$4055.00

Anderson...

\$1910.00...

If you also want to include the mean TOTAL DUE among this group of reservations, change the fourth line of the script to read:

mean of RESERVATIONS TOTAL DUE : item mean .

# mean of

#### Type

Relational Statistical Operator

#### Purpose

The mean of operator calculates the average value in a specified field in all matching records in a related table. The result can appear as a list item in the detail area of a report or as a statistic in the summary area at the end of each group or at the end of the report.

Syntax

mean of TABLENAME|RELATIONSHIP

[named "UNIQUE RELATIONSHIP NAME" ]

[with ( selection criteria) ] FIELDNAME ;|.

Returns

A numeric value.

Usage

The mean of operator calculates the average of all the values in the specified field (the sum of the values divided by the number of values processed). Blank fields are ignored. Fields that have a value of zero are included in the calculation.

There's an important difference between the statistical operator mean and the relational statistical operator mean of. mean finds the average value in the specified field among the records being processed. mean of finds the average value in the specified field among the records related to the records being processed.

Example

for MEMBERS ;

list records

LAST NAME in order ;

mean of RESERVATIONS TOTAL DUE .

end

This script tells DataEase: (1) Process all the MEMBERS records and list each member's LAST NAME in alphabetical order, (2)for each MEMBERS record processed, find all the related records in the RESERVATIONS table (those that have the same MEMBERID), and (3) list the mean TOTAL DUE for each member from the set of related RESERVATIONS records.

The output from this script might look as follows:

 Last Name Mean of Reservations Total Due Adams \$2780.00 Albert \$4430.00 Anders \$4055.00 Anderson... \$1910.00...

If you also want to include the mean TOTAL DUE among this group of reservations, change the fourth line of the script to read:

mean of RESERVATIONS TOTAL DUE : item mean .