ListAvg
Gets the average of all values in a list
Method Signature
ListAvg(list=[string], delimiter=[string], multiCharacterDelimiter=[boolean])
Arguments
Argument
Type
Required
Description
Default
list
string
true
The list to compact
delimiter
string
false
string the list delimiter
,
multiCharacterDelimiter
boolean
false
boolean whether the delimiter is multi-character
false
Examples
Calculate average from query columns
athletes = queryNew( "id,name,bestTime", "integer,varchar,decimal" );
queryAddRow( athletes, [
{
ID : 0,
NAME : "Anne",
BESTTIME : 15.4
},
{
ID : 1,
NAME : "John",
BESTTIME : 12.8
},
{
ID : 2,
NAME : "Sue",
BESTTIME : 9.1
}
] );
writeOutput( "Athlete's average best time is #NumberFormat( listAvg( queryColumnData( athletes, "bestTime" ).toList() ), "0.00" )# seconds." );
Result: Athlete's average best time is 12.43 seconds.
Additional Examples
writeDump( ListAvg( "1,2,3" ) ); // Expected output: 2
// Member Function
listStr = "4,5,6";
writeDump( liststr.listAvg() );
// Expected output: 5
Related
Last updated
Was this helpful?