This is the second of three pages on the statistical category of ECMA-376 5th edition Part 1 (December 2016) section 18.17.7. It covers 22 functions in alphabetical order, GEOMEAN (18.17.7.135) to NORMSINV (18.17.7.232); AVEDEV to GAMMALN come before it. For each function the page gives what it takes and returns, the standard’s example, what [MS-OI29500] v20260818 says Office does differently where it has a note, and what LibreOffice returns. Section numbers are the standard’s own.
How the examples were checked
The standard’s examples and 197 edge cases were written as formulas in
samples/xlsx/oracle/statfn2/formulas.txt (223 formulas). A flat ODS (make-fods.mjs) and
a real XLSX (samples/xlsx/oracle/make-xlsx.mjs, formula cells without cached values) were both
converted to CSV by LibreOffice (soffice --headless --convert-to csv). As on the previous page the
XLSX run is the one quoted: it keeps Excel’s meaning of the names and turns wildcards on. 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). The array functions GROWTH, LINEST and LOGEST were read one element at a time with
INDEX(…, row, column).
MAX, MIN, MAXA, MINA, MEDIAN and MODE: what is a number
The standard treats the plain forms like the rest of the category: logical values and numbers written as text that are typed in the argument list count, while in an array or reference text, logical values and empty cells are ignored and cells holding 0 are included. MAXA and MINA also count logical values (TRUE as 1, FALSE as 0) and numbers in strings inside references; text that is not a number is 0 (standard and LibreOffice agree on the result of the examples). With no numbers at all the result is 0.
| Case (data: A1:D1 = 3, 10, 7, 10; B3 = 0; E2 = TRUE; E3 = FALSE; F1:F4 = 1, “2”, TRUE, 4) | Standard | LibreOffice |
|---|---|---|
MAX(-10,-12,-15,B3) and MIN(10,12,15,B3) (B3 = 0) | the examples print -10 and 10, although the text says a 0 is included | 0 and 0, as the text says. The printed results hold when B3 is empty: -10 and 10 (tested with E1). The standard’s examples are right only for an empty cell. |
MAX(-5,E2), MIN(5,E3) | -5 and 5: a logical value in a reference is ignored | 1 and 0: counted as a number. Difference. |
MAX(E1:E3), MIN(E1:E3) | 0: no numbers | 1 (shown as TRUE) and 0 (shown as FALSE): the logicals are used. Difference. |
MAX(F1:F4), MIN(F1:F4), MAXA(F1:F4), MINA(F1:F4) | 4, 1, 4 and 0 (the text “2” is 0 for the A form) | 4, 1, 4 and 0 |
MAX("a"), MAX(-5,"3"), MEDIAN(1,"2",TRUE), MODE(1,"1",2), GEOMEAN(10.5,{5.3,2.9},"12") | text that reads as a number typed in the list is counted | Err:504 (the parameter list is rejected). Difference. |
MAX({"ABC",TRUE}), MAXA({"ABC",TRUE}) | 0 and 0 | MAX 1 and MAXA 1: the TRUE in the inline array is used. Difference. |
MAX(A2:D2) (four text cells), MAXA(A2:D2) | 0 | 0 and 0 |
The 22 functions
Argument names are the standard’s. Optional arguments are in brackets. Results quoted from the standard are its printed digits; LibreOffice’s are its full precision.
| Function | Arguments and result | Standard’s example | LibreOffice |
|---|---|---|---|
GEOMEAN (.135) | argument-list (logical, number, name, array or reference); the n-th root of the product of the n values; logical values and numbers written as text in the list are included, in an array or reference text, logicals and empty cells are ignored and zeros included. The standard returns #NUM! if any data point is ≤ 0. MS-OI29500 2.1.958: the standard says cells equal to 0 are included in the calculation, Office returns #NUM! for any value ≤ 0 | GEOMEAN(10.5,5.3,2.9) = 5.444454702; GEOMEAN(10.5,{5.3,2.9},"12") = 6.633780588 | 5.4444547024966; the second example Err:504 (text argument rejected); a zero gives 0 (GEOMEAN(1,0), a range holding B3 = 0) where the standard and Office say #NUM!; a negative Err:502; GEOMEAN(F1:F4) 1.5874 (the TRUE counted as 1) |
GROWTH (.138) | known-ys [, [known-xs] [, [new-xs] [, const-flag]]] (arrays): fits y = b·mx and returns the y-values for new-xs. A single-column known-ys makes each column of known-xs a variable, a single row each row; with more than one variable known-ys must be a vector. Omitted known-xs is {1, 2, 3, …} of the size of known-ys; the standard also says omitted new-xs is {1, 2, 3, …}. const-flag FALSE forces b = 1. #NUM! if any known y is zero or negative | months 11 to 16 with units 33100, 47300, 69000, 102000, 150000, 220000 give 32618.20377, 47729.42261, 69841.30086, 102197.0734, 149542.4867, 218821.8762 (the fitted values at the known months), and months 17 and 18 give 320196.72 and 468536.05 | 320196.718363473 and 468536.05418405 for new-xs 17, 18; 32618.2037735398 for the first fitted value and 218821.876214596 for the sixth, so with new-xs omitted LibreOffice returns the values at the known x, which is what the standard’s own example shows and not “{1,2,3,…}” as its text says. With known-xs omitted (GROWTH(B11:B16)) 32618.2037735399; known-xs omitted and new-xs 17: 14410474.07 (x is then 1 to 6); const-flag FALSE 1414600.73. A zero or negative y and known-xs of a different size: Err:502 (Office #NUM! and #REF!, see below) |
HARMEAN (.139) | argument-list (logical, text, number, name, array or reference); n over the sum of 1/Yi. Same treatment of logicals and text as GEOMEAN. #NUM! if any data point is ≤ 0 (MS-OI29500 2.1.960 says the standard’s sentence that cells with 0 are included is wrong: Office returns #NUM!) | HARMEAN(4.6,5.8,8.3,7) = 6.124222; HARMEAN(10.5,{5.3,2.9},"12") = 5.617360 (printed as “HARMMEAN”, a typo) | 6.12422217920201; the second example Err:504; HARMEAN(0,1), a negative value and a range holding 0 Err:502; HARMEAN(F1:F4) 1.3333 (the TRUE counted) |
HYPGEOMDIST (.146) | sample-successes, number-sample, population-successes, number-population (numbers, all truncated to integers); C(M,x)·C(N−M,n−x)/C(N,n). #NUM! if sample-successes < 0, above the lesser of number-sample and population-successes, or below the larger of 0 and number-sample − number-population + population-successes; if number-sample ≤ 0 or > number-population; if population-successes ≤ 0 or > number-population; if number-population ≤ 0 | HYPGEOMDIST(1,4,8,20) = 0.363261 | 0.363261093911249 (and for 1.9, 4.9, 8.9, 20.9, truncated); (4,4,8,20) 0.0144478844; (0,4,8,20) 0.1021671827; Err:502 for sample-successes 5 or -1, number-sample 0 or 21, population-successes 21 and number-population 0. Two cases the standard calls #NUM! give 0: HYPGEOMDIST(0,4,18,20) (x below 4 − 20 + 18 = 2) and population-successes 0 |
INTERCEPT (.170) | known-ys, known-xs (numbers, names, arrays or references); a = ȳ − bx̄ with b = ∑(x−x̄)(y−ȳ)/∑(x−x̄)². Text, logicals and empty cells in an array or reference are ignored, zeros included. #DIV/0! if the line does not meet the y-axis; different counts or no data: unspecified. MS-OI29500 2.1.976: x and y are the sample values, x̄ and ȳ the means; #DIV/0 if the regression line does not intercept the y-axis | INTERCEPT({2,3,9,1,8},{6,5,11,7,5}) = 0.048387097 | 0.0483870967741928 (arrays and cell ranges); all x equal ({3,3}) #DIV/0!; different sizes Err:502 (unspecified in the standard); INTERCEPT(E1,E1) over an empty cell #VALUE!; with a TRUE in the data (F1:F4 against H1:H4) -0.2857, the logical used |
KURT (.188) | argument-list (array, number, name or reference); n(n+1)/((n−1)(n−2)(n−3))·∑((xi−x̄)/s)4 − 3(n−1)²/((n−2)(n−3)), s the sample standard deviation. Logicals and text typed in the list are included. Fewer than four data points, or a zero standard deviation: unspecified | KURT(10.5,12.4,19.4,23.2) and KURT(10.5,{12.4,19.4},23.2) = -3.644621343 | -3.64462134344025 for both; KURT(1,2,3) and KURT(2,2,2,2) #DIV/0! (the standard: unspecified); KURT(1,2,3,4,5,9) 1.66875; KURT(1,2,3,4,"5") Err:504 |
LARGE (.189) | array, k; the k-th largest value. #NUM! if k ≤ 0 or k is more than the number of data points; empty array: unspecified | LARGE({3,5,3,5,4;4,2,4,6,7},3) = 5; with k = 7 the value 4 | 5 and 4; k = 1 gives 7 and k = 10 gives 2; k = 0, -1 and 11 give #VALUE! (the standard: #NUM!); k = 1.9 gives 6, the second largest, so a fractional k is rounded up; an empty or all-text range #VALUE!; LARGE(F1:F4,3) 1 (the TRUE counted); a text k Err:504 |
LINEST (.195) | known-ys [, [known-xs] [, [const-flag] [, stats-flag]]] (arrays; const-flag FALSE forces b = 0). Returns {mn, …, m1, b} and, with stats-flag TRUE, the rows {sen, …, se1, seb; r², sey; F, df; ssreg, ssresid}. Omitted known-xs is {1, 2, 3, …}. MS-OI29500 2.1.985: x and y are sample values; known-ys and known-xs of different size give #REF!; with const-flag FALSE seb is #N/A; vectors of known-xs that are collinear are left out of the regression with coefficient 0 and standard error 0 (which changes df); the syntax in Office has an optional stats-flag after every comma (LINEST(known-ys, [known-xs], [const-flag], [stats-flag])) | LINEST({1,9,5,7},{0,4,2,3},,FALSE): slope 2, y-intercept 1 | 2 and 1. For months 11 to 16 and the units of GROWTH, with stats: m 36445.7142857143, b -388450.476190476; sem 5065.98849739933, seb 68935.9243976779; r² 0.928259429310162, sey 21192.5503532772; F 51.7564563752013, df 4; ssreg 23245076571.4286, ssresid 1796496761.90476. The result has two columns for one variable. With const-flag FALSE: m 8124.84248424843, b 0, sem 1700.18182685344, seb #N/A, df 5. Different sizes of known-ys and known-xs Err:502 (Office #REF!). Collinear x rows ({1,2,3,4} and {2,4,6,8} against y {1,2,3,4}): LibreOffice solves with both rows (m for the second row -0.8333, for the first 2.6667, b 8.9E-16) where Office gives the collinear one a coefficient of 0. Trailing empty arguments (LINEST(ys,xs,,)) are accepted |
LOGEST (.199) | known-ys [, [known-xs] [, [const-flag] [, stats-flag]]]; fits y = b·mx (or b·m1x1·m2x2…) and returns {mn, …, m1, b}; const-flag FALSE forces b = 1; the statistics are those of LINEST (18.17.7.195). MS-OI29500 2.1.987: the standard’s “y = b·mx” is y = b·(m^x); different sizes give #REF!; the syntax has an optional stats-flag as for LINEST | months 11 to 16 and units (GROWTH data): LOGEST(B2:B7,A2:A7,TRUE,FALSE) = 1.463275628 and 495.3047702 | 1.46327562811618 and 495.304770158729. Statistics: sem 0.00263340289142511, seb 0.0358342824357183; r² 0.999808619775818, sey 0.0110163146650732; F 20896.8010994195, df 4; ssreg 2.53601882993857, ssresid 0.000485436755199631. const-flag FALSE: m 2.30039276374379, b 1. Different sizes and a zero y Err:502 |
LOGINV (.200) | probability, mean, standard-dev; emean + standard-dev · NORMSINV(probability). The standard says #NUM! if probability ≤ 0 or ≥ 1 in the function text but “less than 0 or greater than 1” is not what it prints here; MS-OI29500 2.1.988 says Office returns #NUM! for ≤ 0 and ≥ 1. #NUM! if standard-dev ≤ 0 | LOGINV(0.039084,3.5,1.2) = 4.000025219 | 4.00002521868064; LOGINV(0.5,0,1) 1; probability 0, 1, -0.1 and 1.5, and standard-dev 0 and -1 Err:502 |
LOGNORMDIST (.201) | x, mean, standard-dev; NORMSDIST((ln x − mean)/standard-dev), the cumulative lognormal distribution. The standard’s Return paragraph calls it the inverse of the cumulative function, a slip: MS-OI29500 2.1.989 says Office returns the cumulative distribution. #NUM! if x ≤ 0 or standard-dev ≤ 0 | LOGNORMDIST(4,3.5,1.2) = 0.039083556 | 0.0390835557068005; LOGNORMDIST(1,0,1) 0.5; standard-dev 0 and -1 Err:502; x = 0 and x = -1 give 0 where the standard says #NUM! |
MAX (.205) | argument-list (logical, number, name, arrays, reference); the largest value, 0 if there are no numbers. See the table above for logicals and text | MAX(10.4,-3.5,12.6) = 12.6; MAX(10.4,{-3.5,12.6}) = 12.6; MAX({"ABC",TRUE}) = 0; MAX(-10,-12,-15,B3) = -10 | 12.6, 12.6; 1 for the third; 0 for the fourth with B3 = 0 (-10 with an empty cell); MAX(A1:D3) 10 |
MAXA (.206) | argument-list; as MAX but logicals and numbers in strings inside references are included, non-numeric text and empty cells are ignored | MAXA(10.4,-3.5,12.6) = 12.6; MAXA(10.4,{-3.5,12.6}) = 12.6; MAXA({"ABC",TRUE}) = 0; MAXA(-10,-12,-15,B3) = 0 | 12.6, 12.6, 1 (the TRUE counted) and 0; MAXA(-5,"a") 0 (the typed text is 0 here) |
MEDIAN (.209) | argument-list; the middle value, or the mean of the two middle values for an even count. Logicals and text numbers in the list are included; in an array or reference text, logicals and empty cells are ignored | MEDIAN(10,20) = 15; MEDIAN(-3.5,1.4,6.9,-4.5) = -1.05; MEDIAN({-3.5,1.4,6.9},-4.5) = -1.05 | 15, -1.05, -1.05; MEDIAN(F1:F4) 1 (the standard: 2.5, the TRUE is ignored); MEDIAN(E1:E3) 0.5 (TRUE and FALSE used); MEDIAN(A2:D2) of text #VALUE!; MEDIAN(A1:D3) 6 |
MIN (.212) | argument-list; the smallest value, 0 if there are no numbers. The standard’s Description of the argument says “largest” (MS-OI29500 2.1.994: Office treats it as the smallest) | MIN(10.4,-3.5,12.6) = -3.5; MIN(10.4,{-3.5,12.6}) = -3.5; MIN({"ABC",TRUE}) = 0; MIN(10,12,15,B3) = 10 | -3.5, -3.5; 1 for the third; 0 for the fourth with B3 = 0 (10 with an empty cell); MIN(A1:D3) 0 |
MINA (.213) | argument-list; as MIN with the A-form rules (the “largest” slip repeats: MS-OI29500 2.1.995) | MINA(10.4,-3.5,12.6) = -3.5; MINA(10.4,{-3.5,12.6}) = -3.5; MINA({"ABC",TRUE}) = 0; MINA(10,12,15,B3) = 0 | -3.5, -3.5, 0 and 0; MINA(F1:F4) 0; MINA(5,E3) 0 |
MODE (.219) | argument-list; the most frequent value; if several are equally frequent, the first of them in the list. #N/A if there is no duplicate. Text, logicals and empty cells in an array or reference are ignored | MODE(9,1,5,1,9,5,6,6) = 9; MODE(1,9,5,1,9,5,6,6) = 1; MODE(5,1,9,5,1,9,6,6) = 5 | 1, 1 and 1: on a tie LibreOffice returns the smallest value, not the first, so the first and third examples differ. No duplicate (MODE(1,2,3)) #VALUE!, not #N/A; MODE(A1:D1) 10; MODE({1,"a",1}) 1; MODE(1,"1",2) Err:504 |
NEGBINOMDIST (.225) | number-failures, number-successes, success-probability (the first two truncated); C(x+r−1, r−1)·pr(1−p)x. #NUM! if number-failures < 0 or number-successes < 1; the standard says #NUM! if success-probability is ≤ 0 or ≥ 1 in its list while its formula line reads “< 0 or > 1” (MS-OI29500 2.1.999: Office returns #NUM! for ≤ 0 or ≥ 1) | NEGBINOMDIST(6,10,0.5) = 0.076370239 | 0.0763702392578125 (and for 6.9, 10.9, truncated); probability 1.1 Err:502 but probability 0 and 1 give 0 and number-successes 0 gives 0, where the standard says #NUM!; number-failures -1 gives 0.000977 (a value, not an error); NEGBINOMDIST(0,1,0.5) is Err:502 although x = 0 is allowed (it is 0.5), while (0,2,0.5) and (1,1,0.5) give 0.25 |
NORMDIST (.229) | x, mean, standard-deviation, cumulative-flag; the normal density e−(x−μ)²/2σ²/(σ√2π) (FALSE) or its integral from minus infinity to x (TRUE). The standard describes FALSE as the “probability mass function”. #NUM! if standard-deviation ≤ 0 | NORMDIST(42,40,1.5,TRUE) = 0.90878878; NORMDIST(42,40,1.5,FALSE) = 0.10934005 | 0.908788780274132 and 0.109340049783996; NORMDIST(40,40,1,FALSE) 0.398942280401433; NORMDIST(-100,0,1,TRUE) 0; standard-deviation 0 and -1 Err:502; numbers 0 and 1 as the flag work as FALSE and TRUE |
NORMINV (.230) | probability, mean, standard-deviation; the x with NORMDIST(x, mean, standard-deviation, TRUE) = probability. #NUM! if probability ≤ 0 or ≥ 1 or standard-deviation ≤ 0; #N/A if no value can be computed. MS-OI29500 2.1.1001: no iterative search is required; Office returns #NUM! at probability 0 and 1 (the standard’s text elsewhere reads < 0 and > 1) | NORMINV(0.908789,40,1.5) = 42.00000201 | 42.0000020095662; NORMINV(0.5,40,1.5) 40; probability 0 and 1 #VALUE! (not #NUM!); -0.5, 1.5, standard-deviation 0 and -1 Err:502; NORMINV(0.9999999999,0,1) 6.36134088969742 |
NORMSDIST (.231) | z; the standard’s Description and Return text call it the standard normal “distribution for the specified mean and standard deviation” and print the density formula; MS-OI29500 2.1.1002 says Office returns the cumulative standard normal distribution (a, b and c), which is what the examples show | NORMSDIST(1.333333) = 0.90878873; NORMSDIST(-1.5) = 0.06680720 | 0.908788725604095 and 0.066807201268858; NORMSDIST(0) 0.5; NORMSDIST(10) 1; NORMSDIST(TRUE) 0.841344746068543 (TRUE as 1); text #VALUE! |
NORMSINV (.232) | probability; the inverse of the cumulative standard normal distribution (MS-OI29500 2.1.1003 b; the standard says the inverse of the standard normal distribution). #NUM! if probability ≤ 0 or ≥ 1; #N/A if no value can be computed; no iterative search is required (a) | NORMSINV(0.945) = 1.59819314; NORMSINV(0.13) = -1.12639113 | 1.59819313992282 and -1.1263911290388; NORMSINV(0.5) 0; probability 0 and 1 #VALUE!; 1.5 and -0.5 Err:502; NORMSINV(0.9999999) 5.19933758229066 |
GROWTH, LINEST and LOGEST: array results
The three functions return arrays and are written in a file as array formulas (t="array" on the
f element with the ref of the result block, see Formulas).
LINEST returns, for one variable, five rows of two columns: the row of coefficients {m, b}, the row of standard
errors {sem, seb}, {r², sey}, {F, df} and {ssreg, ssresid};
LibreOffice’s result of the standard’s data is in the table above. LOGEST runs the same regression
on the logarithms of the y-values and returns the bases m = eslope and b = eintercept.
Where Office says #REF! for known-ys and known-xs of different size (MS-OI29500 2.1.985 b and 2.1.987 b)
LibreOffice returns Err:502.
Divergence from the standard
- Logical values in references. The standard ignores them in MAX, MIN, MEDIAN, MODE, GEOMEAN, HARMEAN, KURT and INTERCEPT; LibreOffice counts them as numbers. The viewer’s calculator follows the standard (tested for MAX and MIN).
- Text arguments. Text typed in the list (
"12","3") is counted by the standard and rejected with Err:504 by LibreOffice. - Error values. Where the standard says #NUM! LibreOffice returns
Err:502, and for MODE, LARGE, NORMINV and NORMSINV #VALUE!, where it says #N/A or #NUM!. A file stores the error of the program that saved it. - Values where the standard says #NUM!. GEOMEAN with a zero (0), LOGNORMDIST with x ≤ 0 (0), HYPGEOMDIST when sample-successes is below its lower bound or population-successes is 0 (0), NEGBINOMDIST with a probability of 0 or 1 or number-successes 0 (0) and number-failures -1 (0.000977).
- NEGBINOMDIST(0,1,p). LibreOffice returns Err:502; the formula gives p.
- MODE ties. The first most frequent value in the list (standard) against the smallest (LibreOffice).
- MAX/MIN examples. The printed -10 and 10 need an empty B3; with B3 = 0 the result is 0, as the standard’s own rule says.
- Standard text slips. LOGNORMDIST “inverse”, NORMSDIST “mean and standard deviation” and its density formula, MIN and MINA “largest”, GROWTH’s “omitted new-xs is {1,2,3,…}” against its own example, and the “HARMMEAN” spelling; all follow from the notes cited in the table.
- Collinear regressors. LINEST and LOGEST: Office gives collinear vectors coefficient 0 and standard error 0 (MS-OI29500 2.1.985 d); LibreOffice returns a least-squares solution for all of them.
- Printed digits. The standard prints 7 to 9 digits; the oracle agrees with every printed example to the digits printed except that its NORMINV (42.0000020095662) and NORMSDIST (0.908788725604095, standard 0.90878873) show more.
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 MAX and MIN from this page; the other
functions are reported as not calculated. parser-test/test-xlsx-built.mjs checks 11 of its MAX and
MIN results against the LibreOffice CSV and pins the logical-value difference above (107 checks pass).
See also
- Functions: statistical (AVEDEV to GAMMALN): the previous page
- Formulas: references, ranges, array formulas, error values
- Functions: math: SUM, SUMPRODUCT and the log functions
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.958 to 2.1.1003 that name these 22 functions were read and are applied above (GEOMEAN, HARMEAN, INTERCEPT, LINEST, LOGEST, LOGINV, LOGNORMDIST, MIN, MINA, NEGBINOMDIST, NORMINV, NORMSDIST, NORMSINV); the other 9 have no note. The grep for the headings of the notes and the notes themselves were read, not the whole range between them.
- The array output of GROWTH for several variables and the exact shape of LINEST with several x variables were not tested beyond the collinear case.
- The financial functions. PEARSON to ZTEST are on the next page.
Sources
- ECMA-376 5th edition Part 1, research/ooxml/ecma376/p1/part1.txt: GEOMEAN (line 82456), GROWTH (82571), HARMEAN (82628), HYPGEOMDIST (82900), INTERCEPT (83629), KURT (84104), LARGE (84148), LINEST (84261), LOGEST (84400), LOGINV (84468), LOGNORMDIST (84494), MAX (84654), MAXA (84691), MEDIAN (84873), MIN (84959), MINA (84997), MODE (85170), NEGBINOMDIST (85314), NORMDIST (85476), NORMINV (85513), NORMSDIST (85536), NORMSINV (85561); category table lines 77057-77090
- [MS-OI29500] v20260818, research/ooxml/ms/MS-OI29500.txt, notes 2.1.958 (line 19012) to 2.1.1003 (19457)
- LibreOffice, soffice headless, flat ODS and XLSX to CSV: samples/xlsx/oracle/statfn2/