The statistical category of ECMA-376 5th edition Part 1 (December 2016) section 18.17.7 is large. This page covers its first 32 functions in alphabetical order, AVEDEV (18.17.7.17) to GAMMALN (18.17.7.133); the rest follow on the next statistical page. For each function the page gives what it takes and returns, the standard’s example, what [MS-OI29500] v20260818 says Office does differently where that note was read, and what LibreOffice returns. Section numbers are the standard’s own.
How the examples were checked
The standard’s examples and 154 edge cases were written as formulas in
samples/xlsx/oracle/statfn1/formulas.txt. A flat ODS (make-fods.mjs) was converted
to CSV by LibreOffice, and the same formulas were written into a real XLSX with
samples/xlsx/oracle/make-xlsx.mjs (formula cells without cached values) and converted the same
way (soffice --headless --convert-to csv). The two runs differ: in a flat ODS LibreOffice reads
its own function names, so CHIDIST, CHIINV, CHITEST and GAMMAINV give #NAME?, FDIST is left-tailed and
wildcards are off. The XLSX run keeps the Excel meanings, so every number marked “LibreOffice” on
this page comes from the XLSX run. LibreOffice is an implementation, not the standard: where it differs the
difference is reported, not corrected. Its errors appear in its own spellings: Err:502
(invalid argument), Err:504 (error in the parameter list), Err:511 (missing
variable).
Counting and averaging: what is a number
The standard says that for AVERAGE, COUNT, AVEDEV, DEVSQ and related functions a reference contributes only its numbers: logical values, text and empty cells in a reference are ignored, while logical values and numbers written as text typed directly into the argument list are counted. AVERAGEA, COUNTA and the other “A” forms count logical values (TRUE as 1, FALSE as 0) and text (as 0) in references.
| Case | Standard | LibreOffice |
|---|---|---|
COUNT(10,E1) (E1 empty) | 1 | 1 |
COUNT(10,E2) (E2 = TRUE) | 1: a logical in a reference is ignored | 2: counted as a number. Difference. |
COUNT(F1:F4) (1, “2”, TRUE, 4) | 2 | 3. Difference. |
COUNT(1,TRUE,"a","2") | 3 (the number, the logical and the text that reads as a number) | 3 |
COUNT(A2:D2) (four text cells) | 0 | 0 |
AVERAGE(F1:F4) | 2.5 (1 and 4) | 2: the TRUE is counted as 1. Difference. |
AVERAGE(1,"2",TRUE); AVERAGE("a") | the text that reads as a number is counted | #VALUE! for both: text arguments are rejected. Difference. |
AVERAGE(10,E2) against AVERAGEA(10,E2) | 10; 5.5 | AVERAGEA gives 5.5, AVERAGE with E2 = TRUE counts it too |
AVEDEV(F1:F4), DEVSQ(F1:F4) | logical ignored | 1.3333 and 6: the TRUE is used (1, 1, 4). Difference. |
COUNTA(10,E2); COUNTA(A3:D3) (C3 = 5, D3 = a formula giving an empty string) | 2; non-blank cells | 2; 2 (the empty string counts as not blank for COUNTA, as blank for COUNTBLANK: 3 blanks in A3:D3) |
The 32 functions
Argument names are the standard’s. Optional arguments are in brackets.
| Function | Arguments and result | Standard’s example | LibreOffice |
|---|---|---|---|
AVEDEV (.17) | argument-list (logical, number, name, array or reference; may be one array or reference); the average of the absolute deviations from the mean, (1/n)∑|x − x̄|. Logical values and numbers written as text directly in the list are included; in an array or reference, text, logical values and empty cells are ignored and zeros included | AVEDEV(-3.5,1.4,6.9,-4.5) = 4.075 and the same for {-3.5,1.4,6.9,-4.5} | 4.075 for both; AVEDEV(1,"2",TRUE) Err:504 (text typed in the list is rejected, the standard includes it) |
AVERAGE (.18) | argument-list (logical, number, name, text or reference that contains a number); the arithmetic mean. A logical value or text that reads as a number typed in the list is counted; in an array or reference, logical values, text and empty cells are ignored and zeros counted | AVERAGE(1,2,3,4,5) = 3; AVERAGE({1,2;3,4}) = 2.5; AVERAGE({1,2,3,4,5},6,"7") = 4; AVERAGE({1,"2",TRUE,4}) = 2.5 (“the logical value and numeric text are ignored”) | 3; 2.5; AVERAGE({1,2,3,4,5},6,"7") #VALUE!; AVERAGE({1,"2",TRUE,4}) 2 (TRUE counted as 1, the text ignored); a text argument #VALUE! |
AVERAGEA (.19) | argument-list (logical, number, text or reference that contains a number); a logical value or text that reads as a number is counted, TRUE is 1 and FALSE 0, text in an array or reference is 0. The standard also says empty cells and text in a reference are ignored, which contradicts “text evaluates to 0” in the same paragraph; MS-OI29500 2.1.886 settles it: Office includes numbers in a reference and text as 0 | AVERAGEA(10,E1) (E1 empty) = 10; AVERAGEA(10,E2) (TRUE) = 5.5; AVERAGEA(10,E3) (FALSE) = 5 | 10, 5.5 and 5; AVERAGEA(F1:F4) = 1.5 (1, “2” as 0, TRUE as 1, 4) |
AVERAGEIF (.20) | cell-range, selection-criteria [, average-range]; the mean of the cells that meet one condition. Cells with TRUE or FALSE and empty cells in cell-range are ignored; wildcards ? and * (escape with ~) work in text criteria; an empty criteria cell is 0; average-range need not match in size: its top-left cell starts a range of cell-range’s size and shape. No cell matching: the standard says unspecified, Office returns #DIV/0! (MS-OI29500 2.1.887, which also gives #DIV/0! when all cells to average are empty or non-numeric) | values 10, 20, 30 with >15 = 25 | 25; no match #DIV/0!; with an average range and "*es" 6.6667 (wildcards on) |
AVERAGEIFS (.21) | average-range, cell-range-1, selection-criteria-1 [, cell-range-2, selection-criteria-2 [, …]]. The standard says average-range need not match the criteria ranges in size; Office requires the same size and shape (2.1.888 a). Empty cells in average-range are ignored; a criteria cell that is empty counts as 0, TRUE as 1, FALSE as 0. No match, or empty or non-numeric cells: unspecified in the standard | 80.5 and 87.5 for the score table with >70, <90 and <>Incomplete, >80; the third example prints 82.375 | 80.5; 87.5; no match #DIV/0!. The third example (all three columns of B11:D14 as the average range against B11:B14, C11:C14, D11:D14 conditions) gives Err:502 because the ranges are not the same size; with equal-sized ranges the result is 84.5. The 82.375 does not follow from the standard’s data. |
BETADIST (.27) | x, alpha, beta [, [A], [B]] (all numbers); cumulative beta distribution, A = 0 and B = 1 by default. #NUM! if alpha or beta ≤ 0, if x < A or x > B, or if A = B | 0.75, 0.66791152, 0.387523629 | 0.75, 0.667911519678253, 0.387523629489603; alpha 0 Err:502 (#NUM!); x above B gives 1 where the standard says #NUM! |
BETAINV (.28) | probability, alpha, beta [, [A], [B]]; the x with BETADIST(x, alpha, beta, A, B) = probability. #NUM! if alpha or beta ≤ 0, probability ≤ 0 or ≥ 1, or A ≥ B; #N/A if the search does not converge. The standard prints “probability < 0 or > 1” in its Return paragraph; Office returns #NUM! at 0 and 1 too (MS-OI29500 2.1.893 a), and A ≥ B (b); no iterative search is required (c) | 0.29289341, -1.043857765, 0.673654842 | 0.292893218813453, -1.04386001800126, 0.673654403270941: the standard’s printed digits differ from the 7th digit on. Probability 0 gives 0, 1 gives 1; A = B Err:502 |
BINOMDIST (.32) | number-successes, number-trials, success-probability, cumulative-flag; the first two are truncated to integers; TRUE gives P(at most number-successes), FALSE the mass function. #NUM! if number-successes < 0 or > number-trials, or success-probability < 0 or > 1 | 0.205078125 and 0.828125 | both; fractional arguments are truncated (6.9, 10.9 as 6, 10); number_s above trials and a probability above 1 are Err:502 |
CHIDIST (.36) | x, degrees-freedom; P(X > x) of the chi-squared distribution; degrees-freedom truncated. #NUM! if x < 0 or degrees-freedom < 1 or > 1010 | 0.47787835 and 0.089917721 | 0.477878344488724, 0.0899177220310849; df 0 Err:502; df 4.9 treated as 4. x = -1 gives 1 where the standard says #NUM! |
CHIINV (.37) | probability, degrees-freedom; the x with CHIDIST(x, degrees-freedom) = probability. #NUM! if probability < 0 or > 1 or degrees-freedom < 1 or ≥ 1010; #N/A if no value can be computed (the standard); Office does not require an iterative search (MS-OI29500 2.1.897) | 3.356694001 and 8.38343064 | 3.35669398003332 and 8.38343082860838 (later digits differ from the print); probability 1.5 Err:502 |
CHITEST (.38) | actual-range, expected-range (references); the chi-squared statistic ∑(A−E)²/E against df = (r−1)(c−1), or c−1 for one row, r−1 for one column. #N/A if the two ranges differ in number of data points; a single row and column: unspecified | 0.000308 | 0.00030819201700831; ranges of different shape Err:502 (the standard: #N/A) |
CONFIDENCE (.47) | alpha, standard-dev, size; the half-width of a confidence interval for a population mean, normal distribution (MS-OI29500 2.1.900); size truncated. #NUM! if alpha ≤ 0 or ≥ 1, standard-dev ≤ 0 or size < 1 | 1.214775614 and 1.083909234 | 1.21477561439757 and 1.08390923352711; alpha 0, standard deviation 0 and size 0 Err:502; size 12.9 truncated to 12 |
CORREL (.49) | array-1, array-2 (array or reference); the correlation coefficient ∑(x−x̄)(y−ȳ) over the root of ∑(x−x̄)²∑(y−ȳ)²; text, logical values and empty cells are ignored, zeros included. Different sizes, empty arrays and a zero standard deviation: unspecified | -0.714976 | -0.714975604012857; arrays of different size Err:502 (the standard: unspecified); a constant array #DIV/0!; pairs holding text are skipped |
COUNT (.52) | argument-list; counts numbers, dates, and logical values or text that reads as a number typed in the list; in an array or reference only numbers count. Error values in a reference are ignored. The standard types the argument as text; Office requires logical, number, name, text, array or reference (MS-OI29500 2.1.904) | COUNT(1,2,3,4,5) 5; COUNT({1,2,3,4,5}) 5; COUNT({1,2,3,4,5},6,"7") 7; COUNT(10,E1) 1; COUNT(10,E2) 1; see the counting table | COUNT(1,2,3,4,5) 5; COUNT({1,2,3,4,5},6,"7") 7; COUNT(NA()) 0 |
COUNTA (.53) | argument-list; counts arguments that are not references and the non-empty cells of references, values of any type (the standard types it text; Office accepts logical, number, name, text, array or reference: 2.1.905) | COUNTA(1,2,3,4,5) 5; COUNTA({1,2,3,4,5}) printed as 15, a slip (5); COUNTA({1,2,3,4,5},6,"7") 7; COUNTA(10,E1) 1; COUNTA(10,E2) 2 | 5; 7 for ({1,2,3,4,5},6,"7") |
COUNTBLANK (.54) | cell-range (reference); the number of empty cells; a formula returning an empty string counts as empty, a cell holding 0 does not | COUNTBLANK(A2:C2) with A2 and B2 empty, C2 not = 2 | COUNTBLANK(A3:C3) = 2; A3:D3 = 3 (D3 is an empty-string formula result); A1:D1 = 0 |
COUNTIF (.55) | cell-range, selection-criteria; the criteria is a number, expression, reference or text: a comparison operator followed by an operand, with wildcards ? and * (escape with ~) | over 3, 10, 7, 10: "=10" 2, "<>10" 2, ">5" printed as 30, a slip (3); over apples, oranges, grapes, melons: "*es" 3, "??a*" 2, "*l*" 2 | Over 3, 10, 7, 10: "=10" 2, ">5" 3, "<>10" 2, 10 2. Over apples, oranges, grapes, melons: "*es" 3, "??a*" 2, "*l*" 2, "apples" 1 and "APPLES" 1 (not case-sensitive) |
COUNTIFS (.56) | count-range, cell-range-1, selection-criteria-1 [, cell-range-2, selection-criteria-2 [, …]] as the standard prints it, but its three examples pass only criteria pairs, and Office accepts no count-range (2.1.906 a); each cell is counted only if every criterion holds; an empty cell is 0 | the Yes/No table: COUNTIFS(B2:D2,"=Yes") 1; COUNTIFS(B2:B5,"=Yes",C2:C5,"=Yes") 2; COUNTIFS(B5:D5,"=Yes",B3:D3,"=Yes") 1 (the page’s test table sits at rows 6 to 9) | 1, 2, 1 and 3 (B6:B9 alone); with a count range inserted first Err:511. MS-OI29500 2.1.906 says Office does not accept a count range either |
COVAR (.63) | array-1, array-2 (number, name, array or reference); the covariance ∑(x−x̄)(y−ȳ)/n, n the number of pairs; text, logical values and empty cells ignored, zeros included. Different sizes or empty arrays: unspecified | -1.375374 | -1.3753740625; the M1:N5 data 36.76; different sizes Err:502 |
CRITBINOM (.64) | number-trials, success-probability, alpha; the smallest value whose cumulative binomial probability is ≥ alpha. #NUM! if number-trials < 0, success-probability or alpha outside 0 to 1. The standard types number-trials as a number; Excel truncates it (2.1.913) | 4 for (6, 0.5, 0.75) and 6 for (12, 0.3, 0.95) | 4 and 6; negative trials, a probability above 1 and alpha above 1 Err:502; 6.9 trials truncated |
DEVSQ (.89) | argument-list (logical, number, name, array or reference; may be one array or reference); ∑(x−x̄)², same treatment of logicals and text as AVEDEV. For an array or reference holding only text, logicals or empty cells the standard is silent and Office returns #NUM! (2.1.931) | 6.906666667 for DEVSQ(5.6,8.2,9.2) and DEVSQ({5.6,8.2,9.2}) | 6.90666666666666; for an array 6.90666666666667 |
EXPONDIST (.114) | x, lambda, cumulative-flag; density λe−λx (FALSE) or 1 − e−λx (TRUE). #NUM! if x < 0 or lambda ≤ 0 | 1.353352832 and 0.968254364 | 1.35335283236613, 0.968254363621932; x = -1 gives 0 where the standard says #NUM!; lambda 0 Err:502 |
FDIST (.118) | x, degrees-freedom-1, degrees-freedom-2; P(F > x), right-tailed; both degrees truncated. #NUM! if x < 0 or a degree is < 1 or ≥ 1010 | 0.017226183 for (12.345, 3, 4) | 0.0172261831604435; x = -1 and df 0 Err:502; fractions truncated |
FINV (.121) | probability, degrees-freedom-1, degrees-freedom-2; the x with FDIST(x, …) = probability. #NUM! if probability < 0 or > 1 or a degree < 1 or ≥ 1010; #N/A if no value can be computed; Office does not require an iterative search (2.1.952) | 0.940534076 for (0.5, 3, 4) | 0.940534076367756; probability -0.1 and 0 Err:502 |
FISHER (.122) | x; ½ln((1+x)/(1−x)). #NUM! if x ≤ −1 or x ≥ 1 | FISHER(-0.43) = -0.459896681; FISHER(0.578) = 0.659454094 | both; x = 1 and -1 Err:502 (#NUM!) |
FISHERINV (.123) | y; (e2y−1)/(e2y+1); no error condition is stated | the standard prints 0.405321309 for -0.43 (a sign slip); 0.521210269 for 0.578 | -0.405321308689463 and 0.521210268804237 |
FORECAST (.126) | x, known-ys, known-xs (arrays or references); a + bx by linear regression with b = ∑(x−x̄)(y−ȳ)/∑(x−x̄)² and a = ȳ − bx̄. Empty arrays, different counts or zero variance of known-xs: unspecified. MS-OI29500 2.1.955: x and y are sample values, x̄ and ȳ the means | FORECAST(30,{6,7,9,15,21},{20,28,31,38,40}) = 10.60725309 | 10.6072530864198; arrays of different size Err:502; all x the same #DIV/0! |
FREQUENCY (.127) | data-array, bins-array; a vertical array with one element more than bins-array, the last counting values above the highest bin; must be an array formula. Data with no values gives zeros; bins with no values returns the number of data elements; text and empty cells in data are ignored | data 79, 85, 78, 85, 50, 81, 95, 88, 97 with bins 70, 79, 89 gives 1, 2, 4, 2 | 1, 2, 4, 2 (four rows, sum 9). Empty bins or empty data: #VALUE!, where the standard returns the element count or zeros |
FTEST (.128) | array-1, array-2 (number, name, array or reference); the two-tailed probability that the variances are not significantly different; text, logicals and empty cells ignored, zeros included. Fewer than two data points or a zero variance: unspecified | 0.648317847 for 6, 7, 9, 15, 21 and 20, 28, 31, 38, 40 | 0.648317846786175; one value in an array, or a constant array: #VALUE!; the standard calls these cases unspecified |
GAMMADIST (.131) | x, alpha, beta, cumulative-flag; density xα−1e−x/β/(βαΓ(α)) (FALSE) or its integral (TRUE); beta = 1 is the standard gamma, alpha = 1 the exponential with λ = 1/β. #NUM! if x < 0 or alpha ≤ 0 or beta ≤ 0 | 0.03263902 (density) and 0.068093631 (cumulative) for (10, 9, 2) | 0.0326390196740794 and 0.0680936347218484 (the cumulative differs in the 8th digit); x = -1 gives 0 where the standard says #NUM!; alpha 0 Err:502; GAMMADIST(1,1,1,FALSE) 0.367879441171442 |
GAMMAINV (.132) | probability, alpha, beta; the x with GAMMADIST(x, alpha, beta, TRUE) = probability. #NUM! if probability < 0 or > 1 or alpha or beta ≤ 0; #N/A if no value can be computed; Office does not require an iterative search (2.1.957) | 9.997130086 for (0.068094, 9, 2) | 9.99712996747266 for 0.068; probability above 1 and alpha 0 Err:502; probability 0 gives 0 |
GAMMALN (.133) | x; ln Γ(x). #NUM! if x ≤ 0 | GAMMALN(4.5) = 2.453736571 | 2.45373657084244; GAMMALN(1) 0; 0 and -1 Err:502 |
Divergence from the standard
- Logical values in references. The standard ignores them in COUNT, AVERAGE, AVEDEV and DEVSQ; LibreOffice counts them as numbers. The viewer’s calculator follows the standard.
- Text arguments. AVERAGE of text given directly gives #VALUE! in LibreOffice; the standard counts text that reads as a number.
- Error values. Where the standard says #NUM! or #N/A, LibreOffice returns
Err:502. A file stores the error of the program that saved it. - Missing errors. BETADIST above B, CHIDIST and EXPONDIST and GAMMADIST below 0 return values (1, 1, 0, 0) where the standard says #NUM!.
- Printed digits. BETAINV, CHIINV, GAMMADIST and GAMMAINV differ from the standard’s printed examples after six to eight digits; the standard’s numbers come from Excel’s own algorithms.
- The standard’s slips. FISHERINV’s sign, COUNTA’s 15, COUNTIF’s 30 and AVERAGEIFS’s 82.375 are not reproducible from the data.
- BETAINV boundary. The Part 1 text and MS-OI29500 2.1.893 disagree on the inclusive range of the probability; LibreOffice returns 0 and 1 at the ends.
- Unspecified cases. For degenerate input (FTEST with fewer than two points or zero variance, CORREL, COVAR and FORECAST with different sizes or zero spread, AVERAGEIF and AVERAGEIFS with no match, CHITEST on a single cell) the standard says the result is unspecified; LibreOffice returns #VALUE!, #DIV/0! or Err:502 and Office #DIV/0! for AVERAGEIF (2.1.887).
- FREQUENCY with empty bins or empty data gives #VALUE! in LibreOffice; the standard returns the data count or zeros.
- Office notes with no result difference measured here: BETAINV and the other inverse functions need no iterative search (2.1.893 c, 897, 952, 957); AVERAGEIFS needs equal-sized ranges (2.1.888 a); DEVSQ of only text or logicals is #NUM! in Office (2.1.931).
What the viewer does
The viewer shows the value a cell stores and never recalculates a worksheet. The conditional-format
calculator (explorer/formats/xlsx/cf.js) implements COUNT, COUNTA, COUNTBLANK, COUNTIF and
AVERAGE from this page; the other functions are reported as not calculated. parser-test/test-xlsx-built.mjs
checks 18 of its results against the LibreOffice CSV and pins the logical-value difference above.
See also
- Formulas: references, ranges, error values
- Functions: math: SUMIF, SUMIFS and COUNTIF’s siblings
- Functions: database: conditions in a criteria range
Not described on this page
- Excel’s own results: Excel was not run, so the right-hand columns are LibreOffice. The [MS-OI29500] notes 2.1.885 to 2.1.957 were read in round 19 and every note that names one of these 32 functions is applied above (AVEDEV, AVERAGEA, AVERAGEIF, AVERAGEIFS, BETAINV, CHIINV, CONFIDENCE, CORREL, COUNT, COUNTA, COUNTIFS, CRITBINOM, DEVSQ, FINV, FORECAST, GAMMAINV); the other 16 have no note. Each argument table row was re-read against the standard’s section in round 19.
- The financial functions. GEOMEAN to NORMSINV are on the next page, PEARSON to ZTEST on the one after.
Sources
- ECMA-376 5th edition Part 1, research/ooxml/ecma376/p1/part1.txt: AVEDEV (line 77778), AVERAGE (77821), AVERAGEIFS (77926), BETADIST (78120), BINOMDIST (78280), CHIDIST (78648), COUNTIF (79303), FREQUENCY (82231), GAMMADIST (82339), GAMMALN (82410)
- [MS-OI29500] v20260818, research/ooxml/ms/MS-OI29500.txt, notes 2.1.885 (line 18041) to 2.1.957 (19008)
- LibreOffice, soffice headless, flat ODS and XLSX to CSV: samples/xlsx/oracle/statfn1/