Show code in...     

  

 

All Functions Math Functions String Functions Logical Functions
Time Functions Statistical Functions Information Functions
Lookup & Reference Functions Database Functions Financial Functions

Statistical Functions

The only functions available in
ExcelWriterSE and ExcelWriterLE
are sum and average.

Statistical Functions
average

Returns the average (arithmetic mean) of the arguments. In the following example, b8 will contain the average of the values in cells b2 through b7.

	ws.Cells("b8").Formula = "=average(b2:b7)" 
	
count*

Counts the number of cells that contain numbers and numbers within the list of arguments. Arguments that are numbers, dates, or text representations of numbers are counted; arguments that are error values or text that cannot be translated into numbers are ignored. For example, if the values in cells A1:A7 are {"red","yellow", "seven", "blue", 11/2/1999, "green", 8}, count(A1:A7) would equal 3 ("seven", 11/2/1999, 8). To display this result in cell A8, use,

	ws.Cells("A8").Formula = "=count(A1:A7)"
	
counta*

Counts the number of cells that are not empty and the values within a list of arguments. Counta takes up to 30 arguments, which may be either cells or values (not contained in cells). For example, if the values in cells A1:A3 are {January, empty cell, December}, count(A1:A3) would equal 2, and count(A1:A3, "Sunday") would equal 3. To display count(A1:A3) in cell A4, use,

	ws.Cells("A4").Formula = "=counta(A1:A3)"
	
countif*

Counts the number of cells that contain values that meet a specified condition. Countif takes two arguments:

RangeThe range of cells from which cells will be counted if their values meet the specified condition.
Criteria   The condition that a cell must meet to be counted. The condition may be a number, expression, or text.

The following displays in cell G2, the number of cells within A1:D3 that contain values greater than 40.

	ws.cells("G2").formula = "=countif(A1:D3,'>40')"
	
max*

Returns the largest value in a set of values. In the following example, b8 will contain the largest value appearing in cells b2 through b7.

	ws.Cells("b8").Formula = "=max(b2:b7)" 
	
median*

Returns the median value in a set of numbers. For example, if cells b1:b5 contain the numbers {82,65,19,6,301}, median(b1:b5) would return 65. To display this return value in cell b6, use,

	ws.Cells("b6").Formula = "=median(b1:b5)"
	
min*

Returns the smallest value in a set of values. In the following example, b8 will contain the smallest value appearing in cells b2 through b7.

	ws.Cells("b8").Formula = "=min(b2:b7)"
	
mode*

Returns the most frequently occurring, or repetitive, value in an array or range of data. Mode takes up to 30 arguments (number1, number2,...) arguments for which to calculate the mode. You can also use a single array or a reference to an array instead of arguments separated by commas.

The arguments should be numbers, names, arrays, or references that contain numbers. If an array or reference argument contains text, logical values, or empty cells, those values are ignored; however, cells with the value zero are included. If the data set contains no duplicate data points, mode returns the #N/A error value.

The following returns the value that occurs most frequently in the cell range b6:b20.

ws.Cells("c13").Formula = "=mode(b6:b20)"
percentile*

Returns the k-th percentile of values in a range. You can use this function to establish a threshold of acceptance. For example, you can decide to examine candidates who score above the 90th percentile.

Percentile takes two arguments Array and K. Array is the array or range of data that defines relative standing. K is the percentile value in the range 0 to 1, inclusive.

If array is empty or contains more than 8,191 data points, percentile returns the #NUM! error value. If k is nonnumeric, percentile returns the #VALUE! error value. If k is < 0 or if k > 1, percentile returns the #NUM! error value.

ws.Cells("h22").Formula = "=percentile(h12:h18,5)"
stdev*

Estimates standard deviation based on a sample. The standard deviation is a measure of how widely values are dispersed from the average value. To display the estimated standard deviation of the sample of values 12,34,45,56 in cell b6, use,

	ws.Cells("b8").Formula = "=stdev(12,34,45,56)" 
	
stdevp*

Calculates standard deviation based on the entire population. To display the standard deviation of the values 12,34,45,56 in cell b6, use,

	ws.Cells("b6").Formula = "=stdevp(12,34,45,56)" 
	
*This function is not available in ExcelWriterSE, ExcelWriterLE, or ExcelWriterFree. The only functions available in ExcelWriterSE, ExcelWriterLE, and ExcelWriterFree are sum and average.



Copyright © 2005, SoftArtisans, Inc.