Avg() finds the average value of the aggregated data in the expression over a number of records as defined by a group by clause.
Return data type: numeric
||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 app and run it. Then add, at least, the fields listed in the results column to a sheet in your app to see the result.
crosstable (Month, Sales) load * inline [
] (delimiter is '|');
LOAD Customer, Avg(Sales) as MyAverageSalesByCustomer Resident Temp Group By Customer;
Divadip 63.083333This can be checked in the sheet by creating a table including the measure:
Given that the
LOAD Customer,Avg(DISTINCT Sales) as MyAvgSalesDistinct Resident Temp Group By Customer;
Divadip 61Only the distinct values are counted. Divide the total by the number of non-duplicate values.