Avg - script function

Avg() finds the average value of the aggregated data in the expression over a number of records as defined by a group by clause.


Avg([DISTINCT] expr)

Return data type: numeric


Argument Description
expr The expression or field containing the data to be measured.
DISTINCT If the word distinct occurs before the expression, all duplicates will be disregarded.

Examples and results:  

Add the example script to your document and run it. Then add, at least, the fields listed in the results column to a sheet in your document to see the result.

Example Result


crosstable (Month, Sales) load * inline [






] (delimiter is '|');



LOAD Customer, Avg(Sales) as MyAverageSalesByCustomer Resident Temp Group By Customer;


Customer MyAverageSalesByCustomer

Astrida 48.916667

Betacab 44.916667

Canutility 56.916667

Divadip 63.083333

This can be checked in the sheet by creating a table including the measure:

Given that the Temp table is loaded as in the previous example:

LOAD Customer,Avg(DISTINCT Sales) as MyAvgSalesDistinct Resident Temp Group By Customer;

Customer MyAverageSalesByCustomer

Astrida 43.1

Betacab 43.909091

Canutility 55.909091

Divadip 61

Only the distinct values are counted.

Did this information help you?

Thanks for letting us know. Is there anything you'd like to tell us about this topic?

Can you tell us why it did not help you and how we can improve it?