CFLib.org – Common Function Library Project

columnTotal(qryColumn)

Last updated May 13, 2003

author

Scott Barber

Version: 2 | Requires: CF5 | Library: DataManipulationLib

Description:
With this UDF, you can get the total of all rows for any given query column. Assuming of course that the column you specify contains numbers! :-)

Return Values:
Returns a number.

Example:

<cfset foo = queryNew("total")>
<cfset queryAddRow(foo,10)>

<cfloop index="x" from=1 to=10>
	<cfset querySetCell(foo,"total",x,x)>
</cfloop>

<cfoutput>#columnTotal("foo.total")#</cfoutput>

Parameters:

Name Description Required
qryColumn The name and column of the query, i.e. foo.total Yes

Full UDF Source:

/**
 * This UDF calculates the total of a column from a query.
 * Version 2 by Raymond Camden
 * 
 * @param qryColumn 	 The name and column of the query, i.e. foo.total (Required)
 * @return Returns a number. 
 * @author Scott Barber (charlesbarber@hotmail.com) 
 * @version 2, May 13, 2003 
 */
function columnTotal(qryColumn){
	return arraySum(listToArray(evaluate("valueList(" & qryColumn & ")")));
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson