Documentos de Académico
Documentos de Profesional
Documentos de Cultura
P
sgn( P)
i=1
N
a
ip
i
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 94 of 442
where P denotes a permutation of the numbers 1, 2, ..., n and
sgn( P)
is the sign of the
permutation, which is +1 for an even amount of permutations and -1 for an odd amount.
Matrices with a non-zero determinant are invertible.
anchor:MDETERM
Test Cases:
Expression Result Comment
=MDETERM([.B4:.C5]) -2 MDETERM( B4:C5 ) = 2 * 5 4 * 3 = -2
=MDETERM([.A41:C43]) -1
=MDETERM([.B4:.B5]) Error Only square matrices are allowed.
=MDETERM([.A41:.B42]) 0 Singular matrix.
=MDETERM([.B4]) 2 A 1x1 matrix.
See also MINVERSE
Note: This function is called MDET in Excel (2002).
6.5.3 MINVERSE
Summary: Returns the inverse of a matrix.
Syntax: MINVERSE( ForceArray Array matrix )
Returns: Array
Constraints: Only square matrices are allowed.
Semantics: Calculates the inverse
A
1
of matrix A. The matrix A multiplied with its inverse
A
1
results in the unity matrix of the same dimension as A:
A
NN
A
NN
1
=A
NN
1
A
NN
=1
NN
Invertible matrices have a non-zero determinant. If the matrix is not invertible, this function should
return an Error value.
anchor:MINVERSE
Test Cases:
Expression Result Comment
=MINVERSE([.B4:.C5]) =[.M41:.N42] Simple 2x2 matrix.
=MINVERSE([.A41:.C43]) =[.D41:.F43]
Should give an error for Gaussian
algorithms without pivoting.
=MINVERSE([.B4:.B5]) Error Only square matrices are allowed.
=MINVERSE([.A41:.B42]) Error Singular matrix.
=MINVERSE([.B4]) 0.5 1x1 matrix.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 95 of 442
See also MDETERM
Note: This function is called MINV in Excel (2002).
Note: Many implementations use the Gaussian algorithm. However, the Gaussian algorithm for the
determination of the determinant becomes unstable for some data sets if the implementation fails to
perform pivoting. Thus, we include a test case requiring pivoting, to make sure that this important
step is actually performed.
Note: If the matrix is not invertable, an Error must be returned. It could be argued that a division by
zero Error would fit best as the inverse of the determinant is involved in the calculation and it is zero
for non-invertible matrices. However, Gnumeric returns #NUM! and OOo Calc returns #DIV/0!
6.5.4 MMULT
Summary: Multiplies the matrices A and B.
Syntax: MMULT( ForceArray Array A ; ForceArray Array B )
Returns: Array
Constraints: COLUMNS(A)=ROWS(B)
Semantics: Returns the matrix product of the two matrices. The elements
c
mn
of the resulting
matrix
C
MN
=A
KM
B
NK
, are defined by:
c
mn
=
k=1
K
a
km
b
nk
anchor:MMULT
Test Cases:
Expression Result Comment
=MMULT([.B4:.C5];[.B4:.C5])
{=16;28|
21;37}
TODO: Replace result with a range?
=MMULT([.A41:.C43];[.D41:.F43]) =[.J41:.L43]
Matrix multiplied with its inverse results
in a unity matrix.
=MMULT([.B4:.B5];[.A41:.C43]) Error Dimensions must match.
=MMULT([.B4:.C5];[.A41:.C42]) ={10;20;14|16;26;18}
Multiplication of matrices with different
dimension.
TODO: Replace result with a range?
6.5.5 MUNIT
Summary: Creates a unit matrix of a specified dimension N.
Syntax: MUNIT( Integer N )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 96 of 442
Returns: Array
Constraints: The dimension has to be greater than zero.
Semantics: Creates the unit matrix (identity matrix) of dimension N.
1
NN
=
(
1 0 . 0
0 1 . 0
0 0 . 1
)
anchor:MUNIT
Test Cases:
Expression Result Comment
=MUNIT(2) =[.J41:.K42] 2x2 unity matrix
=MUNIT(3) =[.J41:.L43] 3x3 unity matrix
=MUNIT(0) Error Dimension has to greater than zero.
Note: Currently, this is function is only implemented in OOo Calc.
6.5.6 TRANSPOSE
Summary: Returns the transpose of a matrix.
Syntax: TRANSPOSE( Array A )
Returns: Array
Constraints: None
Semantics: Returns the transpose A
T
of a matrix A, i.e. rows and columns of the matrix are
exchanged.
A
MN
T
=
(
a
11
a
21
. a
N1
a
12
a
22
. a
N2
a
1M
a
2M
. a
NM
)
NM
anchor:TRANSPOSE
Test Cases:
Expression Result Comment
=TRANSPOSE([.B4:.C5]) {=2;3|4;5} 2x2 matrix
=TRANSPOSE([.A41:.C43]) =[.G41:.I43] 3x3 matrix
=TRANSPOSE([.B4]) =[.B4] 1x1 matrix
=TRANSPOSE([.A41:.B43]) =[.G41:.I42] 2x3 matrix -> 3x2 matrix
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 97 of 442
=TRANSPOSE([.A41:.C42]) =[.G41:.H43] 3x2 matrix -> 2x3 matrix
Note: This function is called MTRANS in Excel (2002).
6.6 Bit operation functions
6.6.1 General
Evaluators shall support unsigned integer values and results of at least 48 bits (values from 0 to
2^48-1 inclusive).
6.6.2 BITAND
Summary: Returns bitwise and of its parameters
Syntax: BITAND( Integer X ; Integer Y )
Returns: Number
Constraints: X 0, Y 0
Semantics: Returns bitwise and of its parameters. In the result, each bit position is 1 if and only if
all parameters' bits at that position are also 1; else it is 0.
anchor:BITAND
Test Cases:
Expression Result Comment
=BITAND(12;10) 8
The bitwise and of 12 (binary 1100) and 10 (binary 1010) is 8
(binary 1000). This tests all 4 combinations of bits.
=BITAND(7;0) 0 0 is a valid value.
=BITAND(214748
3641;
2147483637)
214748363
3
Test for 31 bits. 2147483641 = 2^31-2-4-1 = 1111...11001 and
2147483637 = 2^31-2-8-1 = 1111...10101 (with 31 binary digits)
=BITAND(429496
7289;
4294967285)
429496728
1
Test for 32 bits. 4294967289 = 2^32-2-4-1 = 1111...11001 and
4294967285 = 2^32-2-8-1 = 1111...10101 (with 32 binary digits)
=BITAND(281474
976710649 ;
28147497671064
5)
281474976
710641
Test for 48 bits. 281474976710649 = 2^48-2-4-1 = 1111...11001 and
281474976710645 = 2^48-2-8-1 = 1111...10101 (with 48 binary
digits)
=BITAND(281474
976710655;
28147497671065
5)
281474976
710655
Test for 48 bits 2^48-1 ANDed with itself is 2^48-1
=BITAND(281474
976710655;
28147497671065
5)<>2814749767
True Test for 48 bits 2^48-1 ANDed with itself is not 2^48.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 98 of 442
10656
See also BITOR, BITXOR, AND
Note: If implementing in C, beware of converting this to a signed type, or to simply a long (on many
architectures a long is only 32 bits). This can be implemented in C if x and y are the input values of
type double, the result must in type double, and unsigned long long is supported and at least 48
bits wide, by using this C expression:
(double) (((unsigned long long) x) & ((unsigned long long) y))
This specification does not require that a list of NumberSequence be accepted, but that is a
plausible extension and may be added in a future edition of this specification. Thus, the text above
is carefully written so that applications which implement that extension have obvious guidance on
what the result should be.
Rationale: The first test case uses 12 (binary 1100) and 10 (binary 1010), because that tests all
four possible bit combinations. The other cases embed these numbers, but insert a binary 1 bit at
the top and bottom (to test that indeed the full range is implemented), as follows:
2147483641 = 2^31-2-4-1 = 1111...11001 (with 31 binary digits)
2147483637 = 2^31-2-8-1 = 1111...10101 (with 31 binary digits)
4294967289 = 2^32-2-4-1 = 1111...11001 (with 32 binary digits)
4294967285 = 2^32-2-8-1 = 1111...10101 (with 32 binary digits)
281474976710649 = 2^48-2-4-1 = 1111...11001 (with 48 binary digits)
281474976710645 = 2^48-2-8-1 = 1111...10101 (with 48 binary digits)
This function was originally implemented in Gnumeric, and since it is broadly useful it is included in
this specification. However, old versions of Gnumeric were limited in handling numbers up to 2^31-
1, with bit 32 was reserved as a sign bit. This was very restrictive; it limited calculations to 32 bits,
yet there was no reason that all applications should be so restricted. This restriction was not noted
in Gnumeric's documentation, so it is not clear it was intended by the original developers.
This specification requires support for at least up to 48 bits. This is because most implementations
use IEEE 754's 64-bit (double) representations for numbers. These have 53-bit mantissas, but
there seemed to be little need to handle exactly 53 bits, and requiring exactly that support might
cause implementation issues without user need. However, there are many applications where 48
bits of support are useful. Implementations that use 32-bit number representations can implement
this function with a more limited domain, but they will not be compliant with this specification. This
seemed reasonable, since users will want to know what range of numbers they can count on, and
this was the largest range that was both useful and relatively easy to implement.
6.6.3 BITLSHIFT
Summary: Returns left shift of value x by n bits (<<)
Syntax: BITLSHIFT( Integer x ; Integer n )
Returns: Number
Constraints: x 0
Semantics: Returns left shift of value x by n bit positions:
If n<0, return BITRSHIFT(x,-n)
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 99 of 442
if n=0, return x
if n>0, return x*2^n
anchor:BITLSHIFT
Test Cases:
Expression Result Comment
=BITLSHIFT(63;2
)
252 Simple left shift
=BITLSHIFT(63;0
)
63 A shift of 0 returns x unchanged
=BITLSHIFT(63;-
2)
15 A negative left shift is a right shift.
=BITLSHIFT(1;47
)
140737488
355328
1 << 47 is 2^47
=BITLSHIFT(214
7483641; 0)
214748364
1
Test for 31 bits. 2147483641 = 2^31-2-4-1 = 1111...11001 (with 31
binary digits)
=BITLSHIFT(429
4967289; 0)
429496728
9
Test for 32 bits. 4294967289 = 2^32-2-4-1 = 1111...11001 (with 32
binary digits)
=BITLSHIFT(281
474976710649 ;
0)
281474976
710649
Test for 48 bits. 281474976710649 = 2^48-2-4-1 = 1111...11001
(with 48 binary digits)
See also BITAND, BITXOR, BITRSHIFT
Note: If implementing in C, beware of converting x to a signed type, or to simply a long (on many
architectures a long is only 32 bits). Note that the results are unsigned.
6.6.4 BITOR
Summary: Returns bitwise or of its parameters
Syntax: BITOR( Integer X ; Integer Y )
Returns: Number
Constraints: X 0, Y 0
Semantics: Returns bitwise or of its parameters. In the result, each bit position is 1 if any of its
parameters' bits at that position are also 1; else it is 0.
anchor:BITOR
Test Cases:
Expression Result Comment
=BITOR(12;10) 14
The bitwise or of 12 (binary 1100) and 10 (binary 1010) is 14
(binary 1110). This tests all 4 combinations of bits.
=BITOR(7;0) 7 0 is a valid value.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 100 of 442
=BITOR(2147483
641;
2147483637)
214748364
5
Test for 31 bits. 2147483641 = 2^31-2-4-1 = 1111...11001 and
2147483637 = 2^31-2-8-1 = 1111...10101 (with 31 binary digits)
=BITOR(4294967
289;
4294967285)
429496729
3
Test for 32 bits. 4294967289 = 2^32-2-4-1 = 1111...11001 and
4294967285 = 2^32-2-8-1 = 1111...10101 (with 32 binary digits)
=BITOR(2814749
76710649 ;
28147497671064
5)
281474976
710653
Test for 48 bits. 281474976710649 = 2^48-2-4-1 = 1111...11001 and
281474976710645 = 2^48-2-8-1 = 1111...10101 (with 48 binary
digits)
=BITOR(2814749
76710655;
28147497671065
5)
281474976
710655
Test for 48 bits 2^48-1 ORed with itself is 2^48-1
=BITOR(2814749
76710655;
28147497671065
5)<>2814749767
10656
True Test for 48 bits 2^48-1 ORed with itself is not 2^48.
See also BITAND, BITXOR, AND
Note: See BITAND. In C, the equivalent operator is |.
6.6.5 BITRSHIFT
Summary: Returns right shift of value x by n bits (>>)
Syntax: BITRSHIFT( Integer x ; Integer n )
Returns: Number
Constraints: x 0
Semantics: Returns right shift of value x by n bit positions:
If n<0, return BITLSHIFT(x,-n)
if n=0, return x
if n>0, return INT(x/2^n)
anchor:BITRSHIFT
Test Cases:
Expression Result Comment
=BITRSHIFT(63;
2)
15 Simple right shift
=BITRSHIFT(63;
0)
63 A shift of 0 returns x unchanged
=BITRSHIFT(63;-
2)
252 A negative right shift is a left shift.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 101 of 442
=BITRSHIFT(63;
48)
0 If you shift all the 1 bits away, the result is 0
=BITRSHIFT(214
7483641; 0)
214748364
1
Test for 31 bits. 2147483641 = 2^31-2-4-1 = 1111...11001 (with 31
binary digits)
=BITRSHIFT(429
4967289; 0)
429496728
9
Test for 32 bits. 4294967289 = 2^32-2-4-1 = 1111...11001 (with 32
binary digits)
=BITRSHIFT(281
474976710649 ;
0)
281474976
710649
Test for 48 bits. 281474976710649 = 2^48-2-4-1 = 1111...11001
(with 48 binary digits)
See also BITAND, BITXOR, BITLSHIFT
Note: If implementing in C, beware of converting x to a signed type, or to simply a long (on many
architectures a long is only 32 bits).
6.6.6 BITXOR
Summary: Returns bitwise exclusive or of its parameters
Syntax: BITXOR( Integer X ; Integer Y )
Returns: Number
Constraints: X 0, Y 0
Semantics: Returns bitwise exclusive or (xor) of its parameters. In the result, each bit position is 1
if one or the other parameters' bits at that position are 1; else it is 0.
anchor:BITXOR
Test Cases:
Expression Result Comment
=BITXOR(12;10) 6
The bitwise xor of 12 (binary 1100) and 10 (binary 1010) is 6
(binary 0110). This tests all 4 combinations of bits.
=BITXOR(7;0) 7 0 is a valid value.
=BITXOR(21474
83641; 2)
214748364
3
Test for 31 bits. 2147483641 = 2^31-2-4-1 = 1111...11001 (with 31
binary digits)
=BITXOR(42949
67289; 2)
429496729
1
Test for 32 bits. 4294967289 = 2^32-2-4-1 = 1111...11001 (with 32
binary digits)
=BITXOR(28147
4976710649 ; 2)
281474976
710651
Test for 48 bits. 281474976710649 = 2^48-2-4-1 = 1111...11001
(with 48 binary digits)
=BITXOR(28147
4976710655; 0)
281474976
710655
Test for 48 bits 2^48-1 XORed with 0 is 2^48-1
=BITXOR(28147
4976710655;
0)<>2814749767
10656
True Test for 48 bits 2^48-1 XORed with 0 is not 2^48.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 102 of 442
See also BITAND, BITOR, OR
Note: See BITAND. In C, the equivalent operator is ^.
6.7 Byte-position text functions
6.7.1 General
Byte-position text functions are like their equivalent ordinary text functions, but manipulate byte
positions rather than a count of the number of characters. Byte positions are integers that may
depend on the specific text representation used by the implementation. Byte positions are by
definition implementation-dependent and reliance upon them reduces interoperability.
The pseudotypes ByteLength and BytePosition are Integers, but their exact meanings and values
are not further defined by this specification.
Rationale: Implementations that store strings as double-byte characters can easily implement these
functions with numeric values exactly equal to Excel. Others will not, in particular, the byte positions
for UTF-8 formats will be different. Thus, we generalize these functions so that they report the byte
position (whatever that means for that particular implementation, which may or may not even
correspond to a real byte position!), and that it is NOT portable to do anything with byte positions
except pass them to other functions that expect byte positions.
This does not specifically require that byte positions of 0 be the starting position. This permits trivial
implementations that implement these byte-position functions as synonyms of their normal
functions, which in many circumstances is sufficient.
6.7.2 FINDB
Summary: Returns the starting position of a given text, using byte positions.
Syntax: FINDB( Text Search ; Text T [ ; BytePosition Start ] )
Returns: BytePosition
Semantics: The same as FIND, but using byte positions.
anchor:FINDB
Test Cases:
Expression Result Comment
=MIDB(abcabc;
FINDB("b";"abcabc"); 1)
b Simple FINDB().
See also FIND , LEFTB , RIGHTB
6.7.3 LEFTB
Summary: Returns a selected number of text characters from the left, using a byte position.
Syntax: LEFTB( Text T [ ; ByteLength Length ] )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 103 of 442
Returns: Text
Semantics: As LEFT, but using a byte position.
anchor:LEFTB
Test Cases:
Expression Result Comment
=LEFTB(abcabc;
FINDB("b";"abcabc"))
"bcabc" Simple LEFTB().
See also LEFT, RIGHT, RIGHTB
6.7.4 LENB
Summary: Returns the length of given text in units compatible with byte positions
Syntax: LENB( Text T )
Returns: ByteLength
Constraints: None.
Semantics: As LEN, but compatible with byte position values.
anchor:LENB
Test Cases:
Expression Result Comment
=LEFTB(abcabc;
LENB("abcabc"))
abcabc
LENB produces results that can be used by
other byte position functions
See also LEN, LEFTB, RIGHTB
6.7.5 MIDB
Summary: Returns extracted text, given an original text, starting position using a byte position, and
length.
Syntax: MIDB( Text T ; BytePosition Start ; ByteLength Length )
Returns: Text
Constraints: Length >= 0.
Semantics: As MID, but using byte positions.
anchor:MIDB
Test Cases:
Expression Result Comment
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 104 of 442
=MIDB("123456789";FIN
DB(123456789;5);3)
"567" Simple use of MIDB.
See also MID, LEFTB, RIGHTB, REPLACEB
6.7.6 REPLACEB
Summary: Returns text where an old text is replaced with a new text, using byte positions.
Syntax: REPLACEB( Text T ; BytePosition Start ; ByteLength Len ; Text New )
Returns: Text
Semantics: As REPLACE, but using byte positions.
anchor:REPLACEB
Test Cases:
Expression Result Comment
=REPLACEB("123456789";FIN
D(123456789;5);LENB(567);
"Q")
"1234Q89" Replacement text may have different length.
See also REPLACE, LEFTB, RIGHTB, MIDB, SUBSTITUTE
6.7.7 RIGHTB
Summary: Returns a selected number of text characters from the right, using byte position.
Syntax: RIGHTB( Text T [ ; ByteLength Length ] )
Returns: Text
Semantics: As RIGHT, but using byte positions.
anchor:RIGHTB
Test Cases:
Expression Result Comment
=RIGHTB("Hello";LE
NB(lo))
"lo" Simple RIGHTB().
See also RIGHT, LEFTB
6.7.8 SEARCHB
Summary: Returns the starting position of a given text, using byte positions.
Syntax: SEARCHB( Text Search ; Text T [ ; BytePosition Start ] )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 105 of 442
Returns: BytePosition
Semantics: As SEARCH, but using byte positions.
anchor:SEARCHB
Test Cases:
Expression Result Comment
=LEFTB(abcabc;
SEARCHB("b";"abcabc"))
bcabc Simple SEARCHB().
See also SEARCH, EXACT, FIND, FINDB
6.8 Complex Number Functions
6.8.1 General
Functions for complex numbers.
6.8.2 COMPLEX
Summary: Creates a complex number from a given real coefficient and imaginary coefficient.
Syntax: COMPLEX( Number Real ; Number Imaginary [ ; Text Suffix ] )
Returns: Complex
Constraints: None
Semantics: Constructs a complex number by the given coefficients. The third parameter Suffix is
optional, and should be either i or j. Upper case I or J are not accepted for the suffix
parameter.
anchor:COMPLEX
Test Cases:
Expression Result Comment
=IMREAL(COMPLEX(1;-3)) 1 Real coefficient
=IMAGINARY(COMPLEX(0;-2;i)) -2
Imaginary coefficient with suffix
parameter
Note: The third parameter is optional. Note that it may get tossed in systems that support Complex
numbers as a full type (instead of just a string).
6.8.3 IMABS
Summary: Returns the absolute value of a complex number
Syntax: IMABS( Complex X )
Returns: Number
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 106 of 442
Constraints: None
Semantics: If X=a+bi or X=a+bj, the absolute value =
.
a
2
+b
2
; if N=r(cos + isin), the absolute
value = r.
anchor:IMABS
Test Cases:
Expression Result Comment
=IMABS(COMPLEX(4;3)) 5
=IMABS(COMPLEX(4;-3)) 5
=IMABS(COMPLEX(-4;3)) 5
=IMABS(COMPLEX(-4;-3)) 5
=IMABS([.B4]) 5 Get complex number from a cell
See also IMARGUMENT
Note: Excel uses Complex(0;0) as the default value for empty cell while OpenOffice.org 2.0 returns
Error in such cases.
6.8.4 IMAGINARY
Summary: Returns the imaginary coefficient of a complex number
Syntax: IMAGINARY( Complex X )
Returns: Number
Constraints: None
Semantics: If X=a+bi or X=a+bj, then the imaginary coefficient is b.
anchor:IMAGINARY
Test Cases:
Expression Result Comment
=IMAGINARY(COMPLEX(4;-3)) -3
=IMAGINARY([.B4]) -3 Get complex number from a cell
See also IMREAL
Note: Excel uses Complex(0;0) as the default value for empty cell while OpenOffice.org 2.0 returns
Error in such case.
6.8.5 IMARGUMENT
Summary: Returns the complex argument of a complex number
Syntax: IMARGUMENT( Complex X )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 107 of 442
Returns: Number
Constraints: None
Semantics: If X=a+bi=r(cos + isin), a or b is not 0 and - < , then the complex argument is
. is expressed by radians. If X=0, then IMARGUMENT(X) is implementation-defined and either 0
or an error.
anchor:IMARGUMENT
Test Cases:
Expression Result Comment
=IMARGUMENT(COMPLEX(3;4)) 0.927295218002
=IMARGUMENT(COMPLEX(3;-4)) -0.927295218002
=IMARGUMENT(COMPLEX(-3;4)) 2.214297435588
=IMARGUMENT(COMPLEX(-3;-4)) -2.214297435588
See also IMABS
Note: Both Excel and OpenOffice.org 2.0 returns Error when N is referenced by a empty cell.
6.8.6 IMCONJUGATE
Summary: Returns the complex conjugate of a complex number
Syntax: IMCONJUGATE( Complex X )
Returns: Complex
Constraints: None
Semantics: If X=a+bi, then the complex conjugate is a-bi.
anchor:IMCONJUGATE
Test Cases:
Expression Result Comment
=IMABS(IMSUB( IMCONJUGATE(CO
MPLEX(3;4)); COMPLEX(3;-4) ))
0
=IMABS(IMSUB( IMCONJUGATE(CO
MPLEX(-3;-4)); COMPLEX(-3;4) ))
0
Note: Excel uses Complex(0;0) as the default value for empty cell while OpenOffice.org 2.0 returns
Error in such case.
6.8.7 IMCOS
Summary: Returns the cosine of a complex number
Syntax: IMCOS( Complex X )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 108 of 442
Returns: Complex
Constraints: None
Semantics: If X=a+bi, then cos(X)=cos(a)cosh(b)-sin(a)sinh(b)i.
anchor:IMCOS
Test Cases:
Expression Result Comment
=IMREAL( IMCOS(COMPLEX(1;1)) ) 0.833730025131
=IMAGINARY( IMCOS(COMPLEX(1;1)
) )
-0.988897705763
See also IMSIN
Note: Excel uses Complex(0;0) as the default value for empty cell while OpenOffice.org 2.0 returns
Error in such case.
6.8.8 IMCOT
Summary: Returns the cotangent of a complex number
Syntax: IMCOT(Complex N)
Returns: Complex
Constraints: None
Semantics: Equivalent to the following (except N is computed only once):
IMDIV(IMCOS(N);IMSIN(N))
anchor:IMCOT
Test Cases:
Expression Result Comment
=IMCOT(PI()/2) 0 Function exists
See also IMTAN
6.8.9 IMCSC
Summary: Returns the cosecant of a complex number
Syntax: IMCSC(Complex N)
Returns: Complex
Constraints: None
Semantics: Equivalent to the following:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 109 of 442
IMDIV(1;IMSIN(N))
anchor:IMCSC
Test Cases:
Expression Result Comment
=IMCSC(PI()/2) 1 Function exists
See also IMSIN
6.8.10 IMCSCH
Summary: Returns the hyperbolic cosecant of a complex number
Syntax: IMCSCH( Complex N )
Returns: Number
Constraints: None
Semantics: Computes the hyperbolic cosecant. This is equivalent to:
IMDIV(1;IMSINH(N))
anchor:IMCSCH
Test Cases:
Expression Result Comment
=IMCSCH(PI()/2) 1 Function exists
See also IMSINH, CSCH
6.8.11 IMDIV
Summary: Divides the second number into the first.
Syntax: IMDIV( Complex X ; Complex Y )
Returns: Complex
Constraints: None
Semantics: Given X=a+bi and Y=c+di, return the quotient
(ac+bd )+(bcad )i
(c
2
+d
2
)
Division by zero returns an Error.
anchor:IMDIV
Test Cases:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 110 of 442
Expression Result Comment
=IMREAL( IMDIV(COMPLEX(5;3);
COMPLEX(1;-1)) )
1 Simple division
=IMAGINARY( IMDIV(COMPLEX(5;3);
COMPLEX(1;-1)) )
4 Simple division
See also IMDIV
6.8.12 IMEXP
Summary: Returns the exponent of e and a complex number.
Syntax: IMEXP( Complex X )
Returns: Complex
Constraints: None
Semantics: If X=a+bi, the result is
e
a
(cos b+i sin b)
.
anchor:IMEXP
Test Cases:
Expression Result Comment
=IMREAL( IMEXP(COMPLEX(1;2)) ) -1.131204383757 Simple exponent
=IMAGINARY( IMEXP(COMPLEX(1;2))
)
2.471726672005 Simple exponent
See also IMLN
6.8.13 IMLN
Summary: Returns the natural logarithm of a complex number.
Syntax: IMLN( Complex X )
Returns: Complex
Constraints: None
Semantics: If X=r(cos + isin ) , is expressed by radians, then the natural logarithm is returned.
anchor:IMLN
Test Cases:
Expression Result Comment
=IMREAL( IMLN(COMPLEX(1;2)) ) 0.804718956217
=IMAGINARY( IMLN(COMPLEX(1;2)) ) 1.107148717794
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 111 of 442
See also IMEXP , IMLOG10
6.8.14 IMLOG10
Summary: Returns the common logarithm of a complex number.
Syntax: IMLOG10( Complex X )
Returns: Complex
Constraints: None
Semantics: If X=r(cos + isin ) , is expressed by radians, then the common logarithm is
returned.
anchor:IMLOG10
Test Cases:
Expression Result Comment
=IMREAL(IMLOG10(COMPLEX(1;2)) ) 0.349485002168
=IMAGINARY( IMLOG10(COMPLEX(1;2
)) )
0.480828578784
See also IMLN , IMPOWER
6.8.15 IMLOG2
Summary: Returns the binary logarithm of a complex number.
Syntax: IMLOG2( Complex X )
Returns: Complex
Constraints: None
Semantics: If X=r(cos + isin ) , is expressed by radians, then the binary logarithm is returned.
anchor:IMLOG2
Test Cases:
Expression Result Comment
=IMREAL( IMLOG2(COMPLEX(1;2)) ) 1.160964047444
=IMAGINARY(IMLOG2(COMPLEX(1;2)) ) 1.597277964688
See also IMLN , IMPOWER
6.8.16 IMPOWER
Summary: Returns the power of N and a complex number.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 112 of 442
Syntax: IMPOWER( Complex X ; Number n )
Returns: Complex
Constraints: None
Semantics: If X=a+bi=r(cos + isin ) , the result is
r
n
(cos n+i sin n)
.
anchor:IMPOWER
Test Cases:
Expression Result Comment
=IMREAL( IMPOWER(COMPLEX(-
1;2); 3) )
11
=IMAGINARY( IMPOWER(COMPLEX(-
1;2); 3) )
-2
See also IMEXP
6.8.17 IMPRODUCT
Summary: Returns the product of complex numbers.
Syntax: IMPRODUCT( { ComplexSequence N }+ )
Returns: Complex
Constraints: None
Semantics: Multiply the complex numbers together. Given two complex numbers X=a+bi and
Y=c+di, the product X*Y = (ac-bd) + (ad+bc)i
anchor:IMPRODUCT
Test Cases:
Expression Result Comment
=IMREAL( IMPRODUCT(COMPLEX(1;
2); COMPLEX(-1;-2); COMPLEX(2;-
3) ))
-6
=IMAGINARY( IMPRODUCT(COMPLE
X(1;2); COMPLEX(-1;-2);
COMPLEX(2;-3) ))
-17
See also IMDIV
6.8.18 IMREAL
Summary: Returns the real coefficient of a complex number
Syntax: IMREAL( Complex N )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 113 of 442
Returns: Number
Constraints: None
Semantics: If N=a+bi or N=a+bj, then the real coefficient is a.
anchor:IMREAL
Test Cases:
Expression Result Comment
=IMREAL(COMPLEX(4;-3)) 4
=IMABS([.B4]) 4 Get complex number from a cell
See also IMAGINARY
Note: Excel uses Complex(0;0) as the default value for empty cell while OpenOffice.org 2.0 returns
Error in such case.
6.8.19 IMSIN
Summary: Returns the sine of a complex number
Syntax: IMSIN( Complex N )
Returns: Complex
Constraints: None
Semantics: If N=a+bi, then sin(N)=sin(a)cosh(b)-cos(a)sinh(b)i.
anchor:IMSIN
Test Cases:
Expression Result Comment
=IMREAL( IMSIN(COMPLEX(1;1)) ) 1.298457581416
=IMAGINARY( IMSIN(COMPLEX(1;1))
)
0.634963914785
See also IMCOS
Note: Excel uses Complex(0;0) as the default value for empty cell while OpenOffice.org 2.0 returns
Error in such case.
6.8.20 IMSEC
Summary: Returns the secant of a complex number
Syntax: IMSEC(Complex N)
Returns: Complex
Constraints: None
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 114 of 442
Semantics: Equivalent to the following:
IMDIV(1;IMCOS(N))
anchor:IMSEC
Test Cases:
Expression Result Comment
=IMCSC(PI()/2) 1 Function exists
See also IMCOS
6.8.21 IMSECH
Summary: Returns the hyperbolic secant of a complex number
Syntax: IMSECH( Complex N )
Returns: Number
Constraints: None
Semantics: Computes the hyperbolic secant. This is equivalent to:
IMDIV(1;IMCOSH(N))
anchor:IMSECH
Test Cases:
Expression Result Comment
=IMSECH(0) 1 Function exists
See also IMCOSH, SECH
6.8.22 IMSQRT
Summary: Returns the square root of a complex number
Syntax: IMSQRT( Complex N )
Returns: Complex
Constraints: None
Semantics: If N=r(cos + isin), is expressed by radians, then the square root of N is returned.
anchor:IMSQRT
Test Cases:
Expression Result Comment
=IMREAL(IMSQRT(COMPLEX(1;-2))) 1.272019649514
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 115 of 442
=IMAGINARY(IMSQRT(COMPLEX(1;-2))) -0,786151377757
See also IMPOWER
6.8.23 IMSUB
Summary: Subtracts the second complex number from the first.
Syntax: IMSUB( Complex X ; Complex Y )
Returns: Complex
Constraints: None
Semantics: Subtract complex number Y from X.
anchor:IMSUB
Test Cases:
Expression Result Comment
=IMREAL( IMSUB(COMPLEX(5;3);
COMPLEX(3;2))
2 Simple complex number subtraction.
=IMAGINARY( IMSUB(COMPLEX(5;3);
COMPLEX(3;2))
1 Simple complex number subtraction.
=IMREAL(IMSUB("5-3i";"2i")) 5
=IMAGINARY(IMSUB("5-3i";"2i")) -5
See also IMSUM
6.8.24 IMSUM
Summary: Sums (add) a set of complex numbers, including all numbers in ranges
Syntax: IMSUM( { ComplexSequence N }+ )
Returns: Complex Number
Constraints: None
Semantics: Adds complex numbers together. Text that cannot be converted to a complex number is
ignored.
It is implementation-defined what happens if this function is given zero parameters; an evaluator
may either produce an Error or the Number 0 if it is given zero parameters.
anchor:IMSUM
Test Cases:
Expression Result Comment
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 116 of 442
=IMREAL(IMSUM(COMPLEX(1;2);
COMPLEX(2;3) ))
2 Simple sum with one parameter
=IMAGINARY(IMSUM(COMPLEX(1;2);
COMPLEX(2;3) ))
5 Sum with two parameters
=IMREAL( IMSUM(COMPLEX(1;2);
[.B4:.B5]))
6
Sum with range parameters. Here
assumes that, [.B4] contains
COMPLEX(2;3), and [.B5] contains
COMPLEX(3;4)
=IMAGINARY( IMSUM(COMPLEX(1;2);
[.B4:.B5]))
9
Sum with range parameters. Here
assumes that, [.B4] contains
COMPLEX(2;3), and [.B5] contains
COMPLEX(3;4)
See also IMSUB
Note: Both Excel and OpenOffice.org 2.0 use COMPLEX(0;0) as the default value for empty cell.
TODO: .B4 and .B5 actually DO NOT contain the numbers claimed, and therefore these tests will
always fail. Need to allocate cells with complex numbers, and then fix the test cases.
6.8.25 IMTAN
Summary: Returns the tangent of a complex number
Syntax: IMTAN(Complex N)
Returns: Complex
Constraints: None
Semantics: Equivalent to the following (except N is computed only once):
IMDIV(IMSIN(N);IMCOS(N))
anchor:IMTAN
Test Cases:
Expression Result Comment
=IMTAN(0) 0 IMTAN exists
See also IMSIN, IMCOS, IMCOT
6.9 Database Functions
6.9.1 General
Database functions use the variables, Database 4.11.8, Field 4.11.9, and Criteria 4.11.10.
The results of database functions may change when the values of the HOST-USE-REGULAR-
EXPRESSIONS or HOST-USE-WILDCARDS properties change. 3.4
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 117 of 442
6.9.2 DAVERAGE
Summary: Finds the average of values in a given field from the records (rows) in a database that
match a search criteria.
Syntax: DAVERAGE( Database D ; Field F ; Criteria C )
Returns: Number
Constraints: Nonef
Semantics: Perform AVERAGE on data records in database D field F that match criteria C.
anchor:DAVERAGE
Test Cases:
Expression Result Comment
=DAVERAGE(TESTDB; "TestID"; [.B36:.B37]) 48 Simple criteria.
See also AVERAGE, COUNT, DSUM, DCOUNT, SUM
6.9.3 DCOUNT
Summary: Counts the number of records (rows) in a database that match a search criteria and
contain numerical values.
Syntax: DCOUNT( Database D ; Field F ; Criteria C )
Returns: Number
Constraints: None
Semantics: Perform COUNT on data records in database D field F that match criteria C.
anchor:DCOUNT
Test Cases:
Expression Result Comment
=DCOUNT(TESTDB; "Bright Stars"; [.B36:.B37]) 2 Simple criteria.
See also COUNT, COUNTA, DCOUNTA, DSUM
6.9.4 DCOUNTA
Summary: Counts the number of records (rows) in a database that match a search criteria and
contain values (as COUNTA).
Syntax: DCOUNTA( Database D ; Field F ; Criteria C )
Returns: Number
Constraints: None
Semantics: Perform COUNTA on data records in database D field F that match criteria C.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 118 of 442
anchor:DCOUNTA
Test Cases:
Expression Result Comment
=DCOUNTA(TESTDB; "Bright Stars"; [.B36:.B37]) 2 Simple criteria.
See also COUNT, COUNTA, DCOUNT, DSUM
Note: KSpread 1.4.2 DCOUNTA does not work if the Criteria are Logical values. E.G., you can't say
"Correct?" with a boolean value below, and expect it to match boolean values in the records. If you
change them all to Numbers (e.g., 0 or 1), so that the Criteria to match is a number and the
True/False computed values become 1 or 0, KSpread works fine.
Also, if KSpread's DCOUNTA has as a Criteria that it must match "1", for some odd reason it also
matches 1/0 (Infinity). Note that in KSpread, 1/0 is not the same as MOD(3;0); the former is
"Infinity", while the latter is #DIV/0! (other spreadsheets consider them the same Error).
6.9.5 DGET
Summary: Gets the single value in the field from the single record (row) in a database that matches
a search criteria.
Syntax: DGET( Database D ; Field F ; Criteria C )
Returns: Number
Constraints: None
Semantics: Extracts the value in field F of the one data record in database D that matches criteria
C. If no records match, or more than one matches, it returns an Error.
anchor:DGET
Test Cases:
Expression Result Comment
=DGET(TESTDB; "TestID";
[.D36:.D37])
2048 Simple criteria, single row answer.
=DGET(TESTDB; "TestID";
[.B36:.B37])
Error
Simple criteria, but multiple row answers so an error
is returned.
See also DMAX, DMIN, DSUM
6.9.6 DMAX
Summary: Finds the maximum value in a given field from the records (rows) in a database that
match a search criteria.
Syntax: DMAX( Database D ; Field F ; Criteria C )
Returns: Number
Constraints: None
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 119 of 442
Semantics: Perform MAX on only the data records in database D field F that match criteria C.
anchor:DMAX
Test Cases:
Expression Result Comment
=DMAX(TESTDB; "TestID"; [.B36:.B37]) 64 Simple criteria.
See also MAX, DMIN, MIN
6.9.7 DMIN
Summary: Finds the minimum value in a given field from the records (rows) in a database that
match a search criteria.
Syntax: DMIN( Database D ; Field F ; Criteria C )
Returns: Number
Constraints: None
Semantics: Perform MIN on only the data records in database D field F that match criteria C.
anchor:DMIN
Test Cases:
Expression Result Comment
=DMIN(TESTDB; "TestID"; [.B36:.B37]) 32 Simple criteria.
See also MIN, DMAX, MAX
6.9.8 DPRODUCT
Summary: Finds the product of values in a given field from the records (rows) in a database that
match a search criteria.
Syntax: DPRODUCT( Database D ; Field F ; Criteria C )
Returns: Number
Constraints: None
Semantics: Multiply together only the data records in database D field F that match criteria C.
anchor:DPRODUCT
Test Cases:
Expression Result Comment
=DPRODUCT(TESTDB; "TestID"; [.B36:.B37]) 2048 Simple criteria.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 120 of 442
See also SUM, DSUM
6.9.9 DSTDEV
Summary: Finds the sample standard deviation in a given field from the records (rows) in a
database that match a search criteria.
Syntax: DSTDEV( Database D ; Field F ; Criteria C )
Returns: Number
Constraints: None
Semantics: Perform STDEV on only the data records in database D field F that match criteria C.
anchor:DSTDEV
Test Cases:
Expression Result Comment
=DSTDEV(TESTDB; "TestID"; [.B36:.B37])
22.6274169
979695
Simple criteria.
See also STDEV, DSTDEVP
6.9.10 DSTDEVP
Summary: Finds the population standard deviation in a given field from the records (rows) in a
database that match a search criteria.
Syntax: DSTDEVP( Database D ; Field F ; Criteria C )
Returns: Number
Constraints: None
Semantics: Perform STDEVP on only the data records in database D field F that match criteria C.
anchor:DSTDEVP
Test Cases:
Expression Result Comment
=DSTDEVP(TESTDB; "TestID"; [.B36:.B37]) 16 Simple criteria.
See also STDEVP, DSTDEV
6.9.11 DSUM
Summary: Finds the sum of values in a given field from the records (rows) in a database that
match a search criteria.
Syntax: DSUM( Database D ; Field F ; Criteria C )
Returns: Number
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 121 of 442
Constraints: None
Semantics: Perform SUM on only the data records in database D field F that match criteria C.
anchor:DSUM
Test Cases:
Expression Result Comment
=DSUM(TESTDB; "TestID"; [.B36:.B37]) 96 Simple criteria.
See also SUM, DMIN, DMAX
6.9.12 DVAR
Summary: Finds the sample variance in a given field from the records (rows) in a database that
match a search criteria.
Syntax: DVAR( Database D ; Field F ; Criteria C )
Returns: Number
Constraints: None
Semantics: Perform VAR on only the data records in database D field F that match criteria C.
anchor:DVAR
Test Cases:
Expression Result Comment
=DVAR(TESTDB; "TestID"; [.B36:.B37]) 512 Simple criteria.
See also VAR, DVARP
6.9.13 DVARP
Summary: Finds the population variance in a given field from the records (rows) in a database that
match a search criteria.
Syntax: DVARP( Database D ; Field F ; Criteria C )
Returns: Number
Constraints: None
Semantics: Perform VARP on only the data records in database D field F that match criteria C.
anchor:DVARP
Test Cases:
Expression Result Comment
=DVARP(TESTDB; "TestID"; [.B36:.B37]) 256 Simple criteria.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 122 of 442
See also VARP, DVAR
6.10 Date and Time Functions
6.10.1 General
6.10.2 DATE
Summary: Constructs a date from year, month, and day of month.
Syntax: DATE( Integer Year ; Integer Month ; Integer Day )
Returns: Date
Constraints: 1904 <= Year <= 9956; 1 <= Month <= 12; 1 <= Day <= 31; Evaluators may evaluate
expressions that do no meet this constraint.
Semantics: This computes the date's serial number given Year, Month, and Day of the Gregorian
calendar. Fractional values are truncated. Month > 12 and Day > days of Month will roll over the
date, computing the result by adding months and days as necessary. The value of the serial number
depends on the current epoch.
anchor:DATE
Test Cases:
Expression Result Comments
=DATE(2005;1;31)=[.C7] True Simple date value.
=DATE(2005;12;31)-
DATE(1904;1;1)
37255 Date differences are computed correctly.
=DATE(2004;2;29)=DATE(2004;2;2
8)+1
True 2004 was a leap year.
=DATE(2000;2;29)=DATE(2000;2;2
8)+1
True 2000 was a leap year.
=DATE(2005;3;1)=DATE(2005;2;28
)+1
True 2005 was not a leap year.
=DATE(2017.5; 1; 2)=DATE(2017;
1; 2)
True Fractional values for year are truncated
=DATE(2006; 2.5; 3)=DATE(2006;
2; 3)
True Fractional values for month are truncated
=DATE(2006; 1; 3.5)=DATE(2006;
1; 3)
True Fractional values for day are truncated
=DATE(2006; 13; 3)=DATE(2007;
1; 3)
True Months > 12 roll over to year
=DATE(2006; 1; 32)=DATE(2006;
2; 1)
True Days greater than month limit roll over to month
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 123 of 442
=DATE(2006; 25;
34)=DATE(2008;2;3)
True Days and months roll over transitively
=DATE(2006;-1;
1)=DATE(2005;11;1)
True Negative months roll year backward
=DATE(2006;4;-
1)=DATE(2006;3;30)
True Negative days roll month backward
=DATE(2006;-4;-
1)=DATE(2005;7;30)
True
Negative days and months roll backward
transitively
=DATE(2003;2;29)=DATE(2003;3;1
)
True Non-leap year rolls forward
See also TIME, DATEVALUE
Rationale: Date values are allowed to wrap around because this provides a convenient way to
compute the next value. This is particularly handy for months, and since it rolls over for months, it
is better for consistency's sake to do the same with days. Excel, OpenOffice.org, and Gnumeric all
perform this wrap-around. Kspread 1.4.2 and Lotus1-2-3v9 limit values to "reasonable" values, and
do not accept and roll over out-of-range values; these programs would require changes to meet this
requirement, but since valid spreadsheet data for these systems would normally not have them
anyway, this should be an upwards-compatible change for them.
Note:
OOo gives an Error for dates less than 15 October 1582, the first day of the Gregorian calendar.
Many implementations do not accept (or process correctly) dates before 1904-01-01 or 1900-03-01.
Some implementations do not allow negative year numbers for the DATE() function, though that is a
plausible extension and is not forbidden by this specification.
6.10.3 DATEDIF
Summary: Returns the difference in years, months, or days of two date numbers.
Syntax: DATEDIF( DateParam StartDate ; DateParam EndDate ; Text Format )
Returns: Number
Constraints: None
Semantics: Compute difference of StartDate and EndDate, in the units given by Format.
The Format is a code from the following table, entered as text, that specifies the format you want
the result of DATEDIF to have.
Table 5 - DATEDIF
format Returns the number of
y Years
m Months. If there is not a complete
month between the dates, 0 will be
returned.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 124 of 442
d Days
md Days, ignoring months and years
ym Months, ignoring years
yd Days, ignoring years
anchor:DATEDIF
Test Cases:
Expression Result Comments
=DATEDIF(DATE(1990;2;15);
DATE(1993;9;15); "y")
3
=DATEDIF(DATE(1990;2;15);
DATE(1993;9;15); "m")
43
The number of months between February 15,
1990, and September 15, 1993.
=DATEDIF(DATE(1990;2;15);
DATE(1993;9;15); "d")
1308
=DATEDIF(DATE(1990;2;15);
DATE(1993;9;15); "md")
0
The day of the month for both start-date and end-
date is the 15th
=DATEDIF(DATE(1990;2;15);
DATE(1993;9;15); "ym")
7
The number of months between February and
September.
=DATEDIF(DATE(1990;2;15);
DATE(1993;9;15); "yd")
212
See also DAYS360, DAYS, Infix Operator -
6.10.4 DATEVALUE
Summary: Returns the date serial number from given text.
Syntax: DATEVALUE( Text D )
Returns: Date
Constraints: None
Semantics: This computes the serial number of the text string D, using the current locale. This
function shall accept ISO date format (YYYY-MM-DD), which is locale-independent. It is
semantically equal VALUE(Date) if Date has a date format, since text matching a date format is
automatically converted to a serial number when used as a Number. If the text of D has a combined
date and time format, e.g. YYYY-MM-DD HH:MM:SS, the integer part of the date serial number is
returned. If the text of Date does not have a date or time format, an evaluator may return an Error.
See VALUE for more information on date formats. The value of the serial number depends on the
current epoch.
anchor:DATEVALUE
Test Cases:
Expression Result Comments
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 125 of 442
=DATEVALUE("2004-12-25")=DATE(2004;12;25) True DATEVALUE
=DATEVALUE("2004-12-25
12:34:56")=DATE(2004;12;25)
True
Only the integer
part is returned
Note: Excel 2000 doesn't allow the input to be a reference, but Excel 2002 does (it allows normal
operations). DATEVALUE is widespread, but is not available in SheetToGo. Other than the test for
"date-formattedness", which you can't count on, this is basically the same as VALUE().
OOo2 returns the full integer+fractional number if passed a combined date and time string.
Gnumeric 1.4 does not allow a combined date and time string.
See also TIME, DATE, TIMEVALUE, VALUE
6.10.5 DAY
Summary: Returns the day from a date.
Syntax: DAY( DateParam Date )
Returns: Number
Constraints: None
Semantics: Returns the day portion of a date.
anchor:DAY
Test Cases:
Expression Result Comments
=DAY(DATE(2006;5;21)) 21 Basic extraction.
=DAY(DATE(2006;12;15)) 15
See also MONTH, YEAR
6.10.6 DAYS
Summary: Returns the number of days between two dates
Syntax: DAYS( DateParam EndDate ; DateParam StartDate )
Returns: Number
Constraints: None
Semantics: Returns the number of days between two dates. If StartDate and EndDate are
Numbers, this is EndDate StartDate. If they are both Text, this is DATEVALUE(StartDate)
DATEVALUE(EndDate).
anchor:DAYS
Test Cases:
Expression Result Comments
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 126 of 442
=DAYS(DATE(1993;4;16);
DATE(1993;9;25))
-162
Simple comparison,
note that negative
results are allowed.
See also DATEDIF, DAYS360, MONTH, YEAR, Infix Operator -
Note: Lotus 1-2-3v9.8 has a function named DAYS but with different semantics. It supports an
optional Basis parameter with many different options. Without the optional parameter, it defaults to
a 30/360 basis, so in Lotus 1-2-3v9.8 DAYS(DATE(1993;4;16); DATE(1993;9;25)) computes -159,
not -162. OpenOffice.org computes -162 for DAYS, as shown above.
6.10.7 DAYS360
Summary: Returns the number of days between two dates using the 360-day year
Syntax: DAYS360( DateParam StartDate ; DateParam EndDate [ ; Integer Method = 0 ] )
Returns: Number
Constraints: 0 <= Method <= 1
Semantics: Returns the number of days between two dates, using the 360-day year system (12 30-
month days). In this system, February always has 30 days and there are no leap years.
If method is 0, it uses the National Association of Securities Dealers (NASD) method, also known as
the U.S. method. If the method is 1, the European method is used.
The US/NASD Method (30US/360):
1. Truncate date values, set sign=1.
2. If StartDate's day-of-month is 31, it is changed to 30.
3. Otherwise, if StartDate's day-of-month is the last day of February, it is changed to 30.
4. If EndDate's day-of-month is 31 and StartDate's day-of-month is 30 (after having applied a
change for #2 or #3, if necessary), EndDate's day-of-month is changed to 30.
Note: This calculation is slightly different from Basis 0 (4.11.6 Basis). Dates are never
swapped.
The European Method (30E/360):
1. Truncate date values, set sign=1.
2. If StartDate is after EndDate then swap dates and set sign=-1.
3. If StartDate's day-of-month is 31, it is changed to 30.
4. If EndDate's day-of-month is 31, it is changed to 30.
Note: Days in February are never changed.
Note: This calculation is identical to Basis 4 (4.11.6 Basis)
For both methods the value then returned is
sign * ((EndDate.year*360 + EndDate.month*30 + EndDate.day) - (StartDate.year*360 +
StartDate.month*30 + StartDate.day))
anchor:DAYS360
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 127 of 442
Test Cases:
Expression Result Comments
=DAYS360(DATE(1993;4;
16); DATE(1993;9;25))
159 Simple comparison
See also DAYS, DATEDIF
Note: There is a bug in Excel versions 97 to 2007 involving dates with 28
th
February, e.g.
DAYS360(DATE(2006;2;28);DATE(2007;2;28)) returns a value of 358 instead of the expected 360 (a
full year). OOoCalc3.0 replicates this behavior for interoperability, see
http://qa.openoffice.org/issues/show_bug.cgi?id=84934. See also
http://en.wikipedia.org/wiki/360_day_calendar.
6.10.8 EDATE
Summary: Returns the serial number of a given date when MonthAdd months is added
Syntax: EDATE( DateParam StartDate ; Number MonthAdd )
Returns: Number
Constraints: None
Semantics: First truncate StartDate and MonthAdd, then add MonthAdd number of months.
MonthAdd can be positive, negative, or 0; if zero, the number representing StartDate (in the current
epoch) is returned.
If after adding the given number of months, the day of month in the new month is larger than the
number of days in the given month, the day of month is adjusted to the last day of the new month.
Then the serial number of that date is returned.
anchor:EDATE
Test Cases:
Expression Result Comments
=EDATE(DATE(2006;1;1;0)=DATE
(2006;1;1)
True If zero, unchanged.
=EDATE(DATE(2006;1;1);0)=DAT
E(2006;1;1)
True
You can pass strings or serial numbers to
EDATE
=EDATE(DATE(2006;1;1);2)=DAT
E(2006;3;1)
True
=EDATE(DATE(2006;1;1);-
2)=DATE(2005;11;1)
True
=EDATE(DATE(2006;3;31);-
1)=DATE(2006;2;28)
True
2006 is not a leap year. Last day of March,
going back to February
=EDATE(DATE(2000;4;30);-
2)=DATE(2002;2;29)
True
2000 was a leap year, so the end of February is
the 29th
=EDATE(DATE(2000;4;5);24)=DA True EDATE isn't limited to 12 months
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 128 of 442
TE(2002;4;5)
See also DAYS, DATEDIF, EOMONTH
Note: This tends to be an add-on function. It is an add-on for both Excel and OpenOffice.org 2.
6.10.9 EOMONTH
Summary: Returns the serial number of the end of a month, given date plus MonthAdd months
Syntax: EOMONTH( DateParam StartDate ; Integer MonthAdd )
Returns: Number
Constraints: None
Semantics: First truncate StartDate and MonthAdd, then add MonthAdd number of months.
MonthAdd can be positive, negative, or 0. Then return the serial number representing the end of that
month. Due to the semantics of this function, the value of DAY(StartDate) is irrelevant.
anchor:EOMONTH
Test Cases:
Expression Result Comments
=EOMONTH(DATE(2006;1;1);0)=D
ATE(2006;1;31)
True
If zero, unchanged just returns end of that
date's month. (January in this case)
=EOMONTH(DATE(2006;1;1);2)=D
ATE(2006;3;31)
True End of month of March is March 31.
=EOMONTH(DATE(2006;1;1);-
2)=DATE(2005;11;30)
True Nov. 30 is the last day of November
=EOMONTH(DATE(2006;3;31);-
1)=DATE(2006;2;28)
True
2006 is not a leap year. Last day of February is
Feb. 28.
=EOMONTH(DATE(2000;4;30);-
2)=DATE(2000;2;29)
True
2000 was a leap year, so the end of February is
the 29th
=EOMONTH(DATE(2000;4;5);24)=
DATE(2002;4;30)
True Not limited to 12 months, and this tests April
=EOMONTH(DATE(2006;1;5);4)=D
ATE(2002;5;31)
End of May is May 31
=EOMONTH(DATE(2006;1;5);5)=D
ATE(2002;6;30)
June 30
=EOMONTH(DATE(2006;1;5);6)=D
ATE(2002;7;31)
July 31
=EOMONTH(DATE(2006;1;5);7)=D
ATE(2002;8;31)
August 31
=EOMONTH(DATE(2006;1;5);8)=D
ATE(2002;9;30)
Sep 30
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 129 of 442
=EOMONTH(DATE(2006;1;5);9)=D
ATE(2002;10;31)
Oct 31
=EOMONTH(DATE(2006;1;5);10)=
DATE(2002;11;30)
Nov. 30
=EOMONTH(DATE(2006;1;5);11)=
DATE(2002;12;31)
Dec. 31
See also EDATE
Note: This tends to be an add-on function. It is an add-on for both Excel and OpenOffice.org 2.
6.10.10 HOUR
Summary: Extracts the hour (0 through 23) from a time.
Syntax: HOUR( TimeParam T )
Returns: Number
Constraints: None
Semantics: Extract from T the hour value, 0 through 23, as per a 24-hour clock. This is equal to:
DayFraction=(T-INT(T))
Hour=INT(DayFraction*24)
anchor:HOUR
Test Cases:
Expression Result Comments
=HOUR(5/24) 5 5/24ths of a day is 5 hours, aka 5AM.
=HOUR(5/24-1/(24*60*60)) 4 A second before 5AM, it's 4AM.
=HOUR("14:00") 14 TimeParam accepts text
See also MONTH, DAY, MINUTE, SECOND
6.10.11 ISOWEEKNUM
Summary: Determines the ISO week number of the year for a given date.
Syntax: ISOWEEKNUM( DateParam Date [ ; Integer Mode = 2 ] )
Returns: Number
Constraints: None
Semantics: Returns the number of the ISO 8601 week in the year for the given date. Note that this
is not the conventional week number used by some applications (for that, see WEEKNUM). In this
system, week number 1 of any year is the week that contains January 4, because (1) Monday is
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 130 of 442
considered the first day of the week, and (2) a week that lies partly in one year and partly in another
is assigned a number in the year in which most of its days lie.
Mode determines the starting day of the week:
Table 6 - ISOWEEKNUM
Mode Week starts on
1 Sunday
2 Monday
anchor:ISOWEEKNUM
Test Cases:
Expression Result Comments
=ISOWEEKNUM(DATE(1995;1;1
);1)
1
January 1, 1995 was a
Sunday.
=ISOWEEKNUM(DATE(1995;1;1
);2)
52
January 1, 1995 was a
Sunday, so if Monday is the
beginning of the week, then
it's week 52 of the previous
year
=ISOWEEKNUM(DATE(1995;1;1
))
52
Default is Monday is
beginning of week (per ISO)
=ISOWEEKNUM(DATE(2000;5;2
1))
=ISOWEEKNUM(DATE(2000;5;2
1);1)
=ISOWEEKNUM(DATE(2000;5;2
1);2)
=ISOWEEKNUM(DATE(2005;1;1
))
=ISOWEEKNUM(DATE(2005;1;2
))
=ISOWEEKNUM(DATE(2006;1;1
))
See also DAY, MONTH, YEAR, WEEKDAY, WEEKNUM
Note: This is named WEEKNUM is OpenOffice.org 2.0.1, ISOWEEKNUM in Gnumeric. The
WEEKNUM in this spec, Excel and Gnumeric is called WEEKNUM_ADD in OpenOffice.org 2.0.1.
6.10.12 MINUTE
Summary: Extracts the minute (0 through 59) from a time.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 131 of 442
Syntax: MINUTE( TimeParam T )
Returns: Number
Constraints: None
Semantics: Extract from T the minute value, 0 through 59, as per a clock. This is equal to:
DayFraction=(T-INT(T))
HourFraction=(DayFraction*24-INT(DayFraction*24))
Minute=INT(HourFraction*60)
anchor:MINUTE
Test Cases:
Expression Result Comments
=MINUTE(1/(24*60)) 1 1 minute is 1/(24*60) of a day.
=MINUTE(TODAY()+1/
(24*60))
1
If you start with today, and add a minute, you get a
minute.
=MINUTE(1/24) 0 At the beginning of the hour, we have 0 minutes.
See also MONTH, DAY, HOUR, SECOND
6.10.13 MONTH
Summary: Extracts the month from a date.
Syntax: MONTH( DateParam Date )
Returns: Number
Constraints: None
Semantics: Takes a date and returns the month portion.
anchor:MONTH
Test Cases:
Expression Result Comments
=MONTH([.C7]) 1 Month extraction from date in cell.
=MONTH(DATE(2006;5;21)) 5 Month extraction from DATE() value.
See also YEAR, DAY
6.10.14 NETWORKDAYS
Summary: Returns the whole number of work days between two dates.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 132 of 442
Syntax: NETWORKDAYS( DateParam Date1 ; DateParam Date2 [ ; [ DateSequence holidays ] [ ;
LogicalSequence workdays ] ] )
Returns: Number
Constraints: None
Semantics: Returns the whole number of days between two dates, ignoring weekends.
Work days are defined as non-weekend, non-holiday days. By default, weekends are Saturdays
and Sundays and there are no holidays.
The optional 3
rd
parameter Holidays can be used to specify a list of dates to be treated as holidays.
Note that this parameter can be omitted as an empty parameter (two consecutive ;; semicolons) to
be able to pass the set of Workdays without Holidays.
The optional 4
th
parameter Workdays can be used to specify a different definition for the standard
work week by passing in a list of Logical values which define which days of the week are workdays.
So, the default definition of the work week excludes Saturday and Sunday and is: {1;0;0;0;0;0;1}. To
define the workweek as excluding Friday and Saturday, the third parameter would be:
{0;0;0;0;0;1;1}.
anchor:NETWORKDAYS
Test Cases:
Expression Result Comments
=NETWORKDAYS(DATE(200
7;1;1),DATE(2007;1;12))
10 Default mode of operation
=NETWORKDAYS(DATE(200
7;1;1),DATE(2007;1;12);DAT
E(2007;1;1))
9 Exclude a single holiday
=NETWORKDAYS(DATE(200
7;1;1),DATE(2007;1;14);DAT
E(2007;1;6))
10
Excluding a holiday that is also a weekend
does not change the results.
=NETWORKDAYS(DATE(200
7;1;1),DATE(2007;1;14);;
{0;0;0;0;0;1;1})
9
Defining the weekend to be
Friday/Saturday
=NETWORKDAYS(DATE(200
7;1;1),DATE(2007;1;14);DAT
E(2007;1;6);{0;0;0;0;0;1;1})
8
Exclude a holiday as well as define the
weekend to be Friday/Saturday
6.10.15 NOW
Summary: Returns the serial number of the current date and time.
Syntax: NOW()
Returns: DateTime
Constraints: None
Semantics: This returns the current day and time serial number, using the current locale. If you
want only the serial number of the current day, use TODAY.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 133 of 442
anchor:NOW
Test Cases:
Expression Result Comments
=NOW()>DATE(
2006;1;3)
True NOW constantly changes, but we know it's beyond this date.
=INT(NOW())=T
ODAY()
True
NOW() is part of TODAY(). WARNING: this test is allowed to fail if
the locale transitions through midnight while computing this test; this
failure is incredibly unlikely to occur in practice.
See also DATE, TIME, TODAY
6.10.16 SECOND
Summary: Extracts the second (the integer 0 through 59) from a time. This function presumes that
leap seconds never exist.
Syntax: SECOND( TimeParam T )
Returns: Number
Constraints: None
Semantics: Extract from T the second value, 0 through 59, as per a clock. Note that this returns an
integer, without a fractional part. Note also that this rounds to the nearest second, instead of
returning the integer part of the seconds. This is equal to:
DayFraction=(T-INT(T))
HourFraction=(DayFraction*24-INT(DayFraction*24))
MinuteFraction=(HourFraction*60-INT(HourFraction*60))
Second=ROUND(MinuteFraction*60)
anchor:SECOND
Test Cases:
Expression Result Comments
=SECOND(1/(24*60*60)) 1 This is one second into today.
=SECOND(1/(24*60*60*2)) 1 Rounds.
=SECOND(1/(24*60*60*4)) 0 Rounds.
See also MONTH, DAY, HOUR, MINUTE
Rationale: Excel 2002, at least, rounds -- which is possibly counter-intuitive.
6.10.17 TIME
Summary: Constructs a time value from hours, minutes, and seconds.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 134 of 442
Syntax: TIME( Number hours ; Number minutes ; Number seconds )
Returns: Time
Constraints: None. Evaluators may first perform INT() on the hour, minute, and second before
doing the calculation.
Semantics: Returns the fraction of the day consumed by the given time, i.e.:
((hours*60*60)+(minutes*60)+seconds)/(24*60*60)
Time is a subtype of number, where a time value of 1 = 1 day = 24 hours.
Hours, minutes, and seconds may be arbitrary numbers (they shall not be limited to the ranges
0..24, 0..59, or 0..60 respectively).
anchor:TIME
Test Cases:
Expression Result Comments
=TIME(0;0;0) 0
All zero arguments becomes midnight, 12:00:00
AM.
=TIME(23;59;59)*60*60*24 86399 This is 11:59:59 PM.
=TIME(11;125;144)*60*60*24 47244
Seconds and minutes roll over transitively; this is
1:07:24 PM.
=TIME(11;0; -117)*60*60*24 39483
Negative seconds roll minutes backwards,
10:58:03 AM
=TIME(11;-117;0)*60*60*24 32580
Negative minutes roll hours backwards, 9:03:00
AM
=TIME(11;-125;-144)*60*60*24 31956
Negative seconds and minutes roll backwards
transitively, 8:52:36 AM
See also DATE
Rationale: There are no tests involving fractions because there is no consensus on them. Excel
2000 performs INT() on all three parameters before doing the calculation; OOo 2.0 does not perform
an INT() first.
Note: Lotus1-2-3v9 limits TIME values to "reasonable" values, and does not roll over values. This
was not accepted, since the ability to roll over values is useful. It is not believed that many extand
documents depend on TIME being limited to reasonable values.
6.10.18 TIMEVALUE
Summary: Returns a time serial number from given text.
Syntax: TIMEVALUE( Text T )
Returns: Time
Constraints: None
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 135 of 442
Semantics: This computes the serial number of the text string T, which is a time, using the current
locale. This function shall accept ISO time format (HH:MM:SS), which is locale-independent. If the
text of T has a combined date and time format, e.g. YYYY-MM-DD HH:MM:SS, the fractional part of
the date serial number is returned. If the text of T does not have a time format, an evaluatormay
attempt to convert the number another way (e.g., using VALUE), or it may return an Error (this is
implementation-dependent).
anchor:TIMEVALUE
Test Cases:
Expression Result Comments
=TIMEVALUE("06:05")=TIME(6;5;0) True
=TIMEVALUE("06:05:07")=TIME(6;5;7) True
=ROUND(TIMEVALUE("1999-11-22
06:05:07");10)=ROUND(TIME(6;5;7);10)
True
Only the fractional
part is returned
See also TIME, DATE, DATEVALUE, VALUE
Note: Excel 2000 doesn't allow the input to be a reference, but Excel 2002 does (it allows normal
operations). TIMEVALUE is widespread, but is not available in SheetToGo. Other than the test for
"time-formattedness", which you can't count on, this is basically the same as VALUE().
OOo2 returns the full integer+fractional number if passed a combined date and time string.
Gnumeric 1.4 does not allow a combined date and time string.
6.10.19 TODAY
Summary: Returns the serial number of today.
Syntax: TODAY()
Returns: Date
Constraints: None
Semantics: This returns the current day's serial number, using current locale. This only returns the
date, not the datetime value. For the specific time of day as well, use NOW.
anchor:TODAY
Test Cases:
Expression Result Comments
=TODAY()>DATE
(2006;1;3)
True Every date TODAY() changes, but we know it's beyond this date.
=INT(TODAY())=
TODAY()
True
TODAY() returns an integer. WARNING: this test is allowed to fail if
the locale transitions through midnight while computing this test;
because TODAY() is referenced twice, in some implementations this
would result in a race condition) This is incredibly unlikely to occur
in practice.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 136 of 442
See also TIME, NOW
6.10.20 WEEKDAY
Summary: Extracts the day of the week from a date; if text, uses current locale to convert to a date.
Syntax: WEEKDAY( DateParam Date [ ; Integer Type = 1 ] )
Returns: Number
Constraints: None
Semantics: Returns the day of the week from a date, as a number from 0 through 7. The exact
meaning depends on the value of Type:
1. When Type is 1, Sunday is the first day of the week, with value 1; Saturday has value 7.
2. When Type is 2, Monday is the first day of the week, with value 1; Sunday has value 7.
3. When Type is 3, Monday is the first day of the week, with value 0; Sunday has value 6.
Table 7 - WEEKDAY
Day of Week Type=1 Result Type=2 Result Type=3 Result
Sunday 1 7 6
Monday 2 1 0
Tuesday 3 2 1
Wednesday 4 3 2
Thursday 5 4 3
Friday 6 5 4
Saturday 7 6 5
anchor:WEEKDAY
Test Cases:
Expression Result Comments
=WEEKDAY(DATE(2006;5;21)) 1 Year-month-date format
=WEEKDAY(DATE(2005;1;1)) 7 Saturday.
=WEEKDAY(DATE(2005;1;1);1) 7 Saturday.
=WEEKDAY(DATE(2005;1;1);2) 6 Saturday.
=WEEKDAY(DATE(2005;1;1);3) 5 Saturday.
See also DAY, MONTH, YEAR
6.10.21 WEEKNUM
Summary: Determines the week number of the year for a given date.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 137 of 442
Syntax: WEEKNUM( DateParam Date [ ; Number Mode = 1 ] )
Returns: Number
Constraints: 1 Mode 2, or 11 Mode 17, or Mode = 21, or Mode = 150
Semantics: Returns the number of the week in the year for the given date.
For Mode={1, 2, 11, 12, ..., 17} the week containing January 1 is the first week of the year, and is
numbered week 1. The week starts on {Sunday, Monday, Monday, Tuesday, ..., Sunday}.
Mode 21 or 150 are both ISO 8601, the week starts on Monday and the week containing the first
Thursday of the year is the first week of the year, and is numbered week 1.
anchor:WEEKNUM
Test Cases:
Expression Result Comments
=WEEKNUM(DATE(2000;5;21)) 22
=WEEKNUM(DATE(2000;5;21);1
)
22
=WEEKNUM(DATE(2000;5;21);2
)
21
=WEEKNUM(DATE(2005;1;1))
=WEEKNUM(DATE(2005;1;2))
=WEEKNUM(DATE(2005;1;3))
=WEEKNUM(DATE(2005;1;4))
=WEEKNUM(DATE(2005;1;1);2)
=WEEKNUM(DATE(2005;1;2);2)
=WEEKNUM(DATE(2005;1;3);2)
=WEEKNUM(DATE(2005;1;4);2)
=WEEKNUM(DATE(2006;1;1))
See also DAY, MONTH, YEAR, WEEKDAY, ISOWEEKNUM
6.10.22 WORKDAY
Summary: Returns the date serial number which is a specified number of days before or after an
input date.
Syntax: WORKDAY( DateParam Date ; Number Offset [ ; [ DateSequence Holidays ] [ ;
LogicalSequence Workdays ] ] )
Returns: DateTime
Constraints: None
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 138 of 442
Semantics: Returns the date serial number for the day that is offset from the input Date parameter
by the number of work days specifed in the Offset parmameter. If Offset is negative, the offset will
return a date prior to Date. If Offset is positive, a date later Date is returned. If Offset is zero, then
Date is returned.
Work days are defined as non-weekend, non-holiday days. By default, weekends are Saturdays
and Sundays and there are no holidays.
The optional 3
rd
parameter Holidays can be used to specify a list of dates to be treated as holidays.
Note that this parameter can be omitted as an empty parameter (two consecutive ;; semicolons) to
be able to pass the set of Workdays without Holidays.
The optional 4
th
parameter Workdays can be used to specify a different definition for the standard
work week by passing in a list of Logical values which define which days of the week are workdays.
Note: The default definition of the work week that excludes Saturday and Sunday and is:
{1;0;0;0;0;0;1}. To define the workweek as excluding Friday and Saturday, the third parameter would
be: {0;0;0;0;0;1;1}.
anchor:WORKDAY
Test Cases:
Expression Result Comments
=WORKDAY(DATE(2006;12;
31),3)=DATE(2007;1;3)
TRUE Default mode of operation
=WORKDAY(DATE(2006;12;
31),-5)=DATE(2006;12;25)
TRUE Negative offset
=WORKDAY(DATE(2006;12;
31),3,DATE(2007,1,1))=DATE
(2007;1;4)
TRUE
Holiday in the interval causes the returned
value to be pushed out
=WORKDAY(DATE(2006;12;
31),-
5;DATE(2006;12;25))=DATE(
2006;12;22)
TRUE Exclude a holiday with a negetive offset
=WORKDAY(DATE(2006;12;
31),-5;DATE(2006;12;25);
{0,0,0,0,0,1,1)=DATE(2006;1
2;21)
TRUE
Negative offset, a holiday and a Sunday-
Thursday work week
6.10.23 YEAR
Summary: Extracts the year from a date given in the current locale of the evaluator.
Syntax: YEAR( DateParam D )
Returns: Number
Constraints: None
Semantics: Parses a date-formatted string in the current locale's format and returns the year
portion.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 139 of 442
If a year is given as a two-digit number, as in "05-21-15", then the year returned is either 1915 or
2015, depending upon the break point in the calculation context. In an OpenDocument document,
this break point is determined by HOST-NULL-YEAR.
Evaluators shall support extracting the year from a date beginning in 1900. Three-digit year
numbers precede adoption of the Gregorian calendar, and may return either an Error or the year
number. Four-digit year numbers preceding 1582 (inception of the Gregorian Calendar) may return
either an Error or the year number. Four-digit year numbers following 1582 should return the year
number.
anchor:YEAR
Test Cases:
Expression Result Comments
=YEAR(DATE(1904;1;1)) 1904 Extracts year from a given date.
See also MONTH, DAY, VALUE
6.10.24 YEARFRAC
Summary: Extracts the number of years (including fractional part) between two dates
Syntax: YEARFRAC( DateParam StartDate ; DateParam EndDate [ ; Basis Basis = 0 ] )
Returns: Number
Constraints: None
Semantics: Computes the fraction of the number of years between a StartDate and EndDate.
Basis is the system for determining how many days are in a month or year.
Note: The Basis default is not the actual number of days in a month or year. 4.11.6
anchor:YEARFRAC
Test Cases:
Expression Result Comments
=YEARFRAC(DATE(1999;1;1);DAT
E(1999;6;30);0)
0.497222222
=YEARFRAC(DATE(1999;1;1);DAT
E(1999;6;30);1)
0.493150685
=YEARFRAC(DATE(1999;1;1);DAT
E(1999;6;30);2)
0.5
=YEARFRAC(DATE(1999;1;1);DAT
E(1999;6;30);3)
0.493150685
=YEARFRAC(DATE(1999;1;1);DAT
E(1999;6;30);4)
0.497222222
=YEARFRAC(DATE(1999;1;1);DAT
E(1999;7;1);0)
0.5
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 140 of 442
=YEARFRAC(DATE(1999;1;1);DAT
E(1999;7;1);1)
0.495890411
=YEARFRAC(DATE(1999;1;1);DAT
E(1999;7;1);2)
0.502777778
=YEARFRAC(DATE(1999;1;1);DAT
E(1999;7;1);3)
0.495890411
=YEARFRAC(DATE(2000;1;1);DAT
E(2000;6;30);0)
0.497222222
=YEARFRAC(DATE(2000;1;1);DAT
E(2000;6;30);1)
0.494535519
=YEARFRAC(DATE(2000;1;1);DAT
E(2000;6;30);2)
0.502777778
=YEARFRAC(DATE(2000;1;1);DAT
E(2000;6;30);3)
0.495890411
=YEARFRAC(DATE(2000;1;1);DAT
E(2000;6;30);4)
0.497222222
=YEARFRAC(DATE(2000;1;15);DA
TE(2000;9;17);0)
0.672222222
=YEARFRAC(DATE(2000;1;15);DA
TE(2000;9;17);1)
0.672131148
=YEARFRAC(DATE(2000;1;15);DA
TE(2000;9;17);2)
0.683333333
=YEARFRAC(DATE(2000;1;15);DA
TE(2000;9;17);3)
0.673972603
=YEARFRAC(DATE(2000;1;15);DA
TE(2000;9;17);4)
0.672222222
=YEARFRAC(DATE(2000;1;1);DAT
E(2001;1;1);0)
1
=YEARFRAC(DATE(2000;1;1);DAT
E(2001;1;1);1)
1
=YEARFRAC(DATE(2000;1;1);DAT
E(2001;1;1);2)
1.016666667
=YEARFRAC(DATE(2000;1;1);DAT
E(2001;1;1);3)
1.002739726
=YEARFRAC(DATE(2000;1;1);DAT
E(2001;1;1);4)
1
=YEARFRAC(DATE(2001;1;1);DAT
E(2002;1;1);0)
1
=YEARFRAC(DATE(2001;1;1);DAT
E(2002;1;1);1)
1
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 141 of 442
=YEARFRAC(DATE(2001;1;1);DAT
E(2002;1;1);2)
1.013888889
=YEARFRAC(DATE(2001;1;1);DAT
E(2002;1;1);3)
1
=YEARFRAC(DATE(2001;1;1);DAT
E(2002;1;1);4)
1
=YEARFRAC(DATE(2001;12;5);DA
TE(2001;12;30);0)
0.069444444
=YEARFRAC(DATE(2001;12;5);DA
TE(2001;12;30);1)
0.068493151
=YEARFRAC(DATE(2001;12;5);DA
TE(2001;12;30);2)
0.069444444
=YEARFRAC(DATE(2001;12;5);DA
TE(2001;12;30);3)
0.068493151
=YEARFRAC(DATE(2001;12;5);DA
TE(2001;12;30);4)
0.069444444
=YEARFRAC(DATE(2000;2;5);DAT
E(2006;8;10);0)
6.513888889
=YEARFRAC(DATE(2000;2;5);DAT
E(2006;8;10);1)
6.509972624
=YEARFRAC(DATE(2000;2;5);DAT
E(2006;8;10);2)
6.605555556
=YEARFRAC(DATE(2000;2;5);DAT
E(2006;8;10);3)
6.515068493
=YEARFRAC(DATE(2000;2;5);DAT
E(2006;8;10);4)
6.513888889
=YEARFRAC(DATE(2003;12;6);DA
TE(2004;3;5);1)
0.245901639
=YEARFRAC(DATE(2003;12;31);D
ATE(2004;3;31);1)
0.24863388
=YEARFRAC(DATE(2004;10;1);DA
TE(2005;1;11);1)
0.279452055
=YEARFRAC(DATE(2004;10;26);D
ATE(2005;2;6);1)
0.282191781
=YEARFRAC(DATE(2004;11;20);D
ATE(2005;3;4);1)
0.284931507
=YEARFRAC(DATE(2004;12;15);D
ATE(2005;3;30);1)
0.287671233
=YEARFRAC(DATE(2000;12;1);DA
TE(2001;1;16);1)
0.126027397
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 142 of 442
=YEARFRAC(DATE(2000;12;26);D
ATE(2001;2;11);1)
0.128767123
=YEARFRAC(DATE(2002; 2;
28);DATE(2002; 12; 31);0)
0.836111111
Known bug in older versions of
Excel.
=YEARFRAC(DATE(2003;11;1);DA
TE(2004;5;1);1)*1000
497.2677596
Example from ISDA, tests to make
sure that actual/actual is
actual/actual (Euro), aka AFB
Note: Date calculations are easy to get wrong, and there are multiple interpretations. This is why
there are so many test cases. http://www.isda.org/c_and_a/pdf/mktc1198.pdf describes three
different actual/actual systems; the text above uses AFB, aka actual/actual (Euro), as the
actual/actual system. The blog at http://ewbi.blogs.com/develops/2003/10/excel_yearfrac_.html
notes that =YEARFRAC(DATE(2002; 2; 28);DATE(2002; 12; 31);0) in Excel 97 SR-2 gives
0.833333333, but Exel 2003 gives 0.83611111 (a day's difference!). NASD 30/360 is defined in
http://www.investmentstudio.com/help_functions.html under YEARFRAC.
In the US (NASD) 30/360 (basis=0), months are presumed to always be 30 days long, and the year
is considered to always be 360 days long. If StartDate is day 31 of a month, it is set to be day 30 of
that month. If EndDate is day 31 of a month, then there are two possibilities: if the day of StartDate
is less than 30, it is considered day 1 of the next month; otherwise it is set to day 30 of that month.
Note: There are other actual/actual systems, for which currently there are no standard basis
assignments. Future versions of this specification may add them.
See also DATEDIF
6.11 External Access Functions
6.11.1 General
OpenFormula defines two functions, DDE and HYPERLINK, for accessing external data.
6.11.2 DDE
Summary: Returns data from a DDE request
Syntax: DDE( Text server ; Text topic ; Text item [ ; Integer Mode = 0 ] )
Returns: Number|Text
Constraints: None
Semantics: Performs a DDE request and returns its result. The request invokes the service server
on the topic named as topic, requesting that it reply with the information on item.
Evaluators may choose to not perform this function on every recalculation, but instead cache an
answer and require a separate action to re-perform these requests. Evaluators shall perform this
request on initial load when their security policies permit it.
Note: The server soffice is used for OpenOffice.org and StarOffice. In this case the topic is a
document's complete file name or IRL, including path specification. The item is a spreadsheet's cell
address respectively range address or a text document's section name.
Mode is an optional parameter that determines how the results are returned:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 143 of 442
Table 8 - DDE
Mode Effect
0 or missing Data converted to number using VALUE in the number style's locale of the
default table cell style
1 Data converted to number using VALUE in the English-US (en_US) locale
2 Data retrieved as text (not converted to number)
In an OpenDocument spreadsheet document the default table cell style is specified with
table:default-cell-style-name. Its number:number-style specified by style:data-
style-name specifies the locale to use in the conversion.
The DDE function is non-portable because it depends on availability of external programs (server
parameter) and their interpretation of the topic and item parameters.
anchor:DDE
Test Cases:
Expression Result Comments
=DDE("soffice";"file:///documents
/test.ods";"Sheet1.B3")
7
=DDE("soffice";"file:///documents
/test.ods";"Sheet1.B3";1)
7
=DDE("soffice";"file:///documents
/test.ods";"Sheet1.B3";2)
"7"
Note: This is in OpenOffice.org, not in Excel.
6.11.3 HYPERLINK
Summary: Returns a Text or Number result and adds a string to the IRI part of a hyperlink cell.
Syntax: HYPERLINK( Text IRI [ ; Text|Number FunctionResult ] )
Returns: Text or Number
Constraints: None
Semantics: The IRI parameter specifies the link target added to the hyperlink cell, while the
FunctionResult parameter is shown as part of the formula result in the cell. If FunctionResult is
omitted, the IRI will be used for both the IRI and the cell result. If FunctionResult is Text, a Text
result is returned. If FunctionResult is Number, a Number result is returned.
If a formula contains a HYPERLINK function, the cell becomes a "hyperlink cell". Clicking on this cell
will execute the contained hyperlink. Therefore it is irrelevant if the HYPERLINK function is really
evaluated (it may i.e. be located in a non-executed part of an IF function) the cell will always be a
hyperlink cell, even if the formula evaluates to a number or a Boolean value. The only exception to
this rule is if an Error code would be part of the IRI. In this case no hyperlink cell will be created.
In a hyperlink cell, all other functions affect both the current IRI and the cell text. Therefore the
formula has to be evaluated twice. In the first run using the IRI part of all hyperlink functions, and in
the second run using the FunctionResult part.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 144 of 442
anchor:HYPERLINK
Test Cases:
Expression Result Hyperlink IRI Comments
=HYPERLINK( "http: //w
ww. example. org")
"http://www.exampl
e.org"
http: //www. example. o
rg
The function adds
"http://www.exampl
e.org" to the IRI of
the hyperlink cell
and returns the
same text which is
used as formula
result.
=HYPERLINK( "http: //w
ww. example. org"; "Cli
ck here")
Click here
http: //www. example. o
rg
Adds
"http://www.exampl
e.org" to the IRI of
the hyperlink cell,
but returns the text
"Click here" which
is used as formula
result.
=HYPERLINK( "http: //w
ww. ") &
"example. org"
"http://www.exampl
e.org"
http: //www. example. o
rg
Adds "http://www."
to the IRI and the
cell result. The
following text
"example.org" is
also added to both
the IRI and the cell
result
=HYPERLINK( "http: //w
ww. "; Click ) &
"example. org"
"Click example.org"
http: //www. example. o
rg
Results in a
hyperlink cell with
the IRI
http://www.exampl
e.org. The visible
result of the cell is
"Click
example.org".
=HYPERLINK( "") &
"http: //www. example.
org"
"http://www.exampl
e.org"
http: //www. example. o
rg
The text following is
added to both the
IRI and the cell
result.
=HYPERLINK( ""; "Click
") &
"http: //www. example.
org"
"Click
http://www.example.
org"
http: //www. example. o
rg
The text following is
added to both the
IRI and the cell
result.
=MID( HYPERLINK( "http
: //www. example. org";
"Click here") ; 1; 5)
"Click" http:
Functions operate
on both the IRI and
the cell result.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 145 of 442
=IF( TRUE( ) ; HYPERLINK
( http: //www. example
. org) ; something)
"http://www.exampl
e.org"
http: //www. example. o
rg
The HYPERLINK
function is
evaluated.
=IF( FALSE( ) ; HYPERLIN
K( http: //www. exampl
e. org) ; something)
"something" something
Results in a
hyperlink cell
though the
HYPERLINK
function will not be
evaluated. The cell
contains the (not
working) IRI and
the result
"something".
=IF( FALSE( ) ; HYPERLIN
K( http: //www. exampl
e. org) ; 1)
1 1
Results in a
hyperlink cell with
the numerical result
1 and the (not
working) IRI "1".
=IF( FALSE( ) ; HYPERLIN
K( http: //www. exampl
e. org) ; 1=1)
TRUE TRUE
Results in a
hyperlink cell with
the logical result
TRUE and the (not
working) IRI
"TRUE".
=HYPERLINK( http: //w
ww. example. org) &
( 1/0)
Error
No hyperlink
created on error.
=HYPERLINK("http://www1.
example.org/";"example1")
& " or " &
HYPERLINK("http://www2.e
xample.org/";"example2")
"example1 or
example 2"
http://www1.example.org/ or
http://www2.example.org/
Again, the
operations work on
both the IRIs and
cell texts, resulting
in a non-working
IRI.
=HYPERLINK( "http: //w
ww. example. org"; 42)
42
http: //www. example. o
rg
If FunctionResult is
Number, Number is
returned.
Note: The HYPERLINK function originated in Excel. Much of its bizarre semantics results from the
fact that the Hyperlink attribute in Excel can be applied only to a whole cell, hence the weird
behavior that concatenation of HYPERLINK function's parameters and other formula text result in
the entire string being one Hyperlink, or concatenating two HYPERLINK functions does not result in
two different Hyperlinks, but instead produces a Hyperlink with an invalid IRI.
6.12 Financial Functions
6.12.1 General
The financial functions are defined for use in financial calculations.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 146 of 442
An annuity is a recurring series of payments. A "simple annuity" is one where equal payments are
made at equal intervals, and the compounding of interest occurs at those same intervals. The time
between payments is called the "payment interval". Where payments are made at the end of the
payment interval, it is called an "ordinary annuity". Where payments are made at the beginning of
the payment interval, it is called an "annuity due". Periods are numbered starting at 1.
6.12.2 ACCRINT
Summary: Calculates the accrued interest for securities with periodic interest payments.
Syntax: ACCRINT( DateParam issue ; DateParam first ; DateParam settlement ; Number coupon ;
Number par ; Integer frequency [ ; Basis basis = 0 [ ; Logical calc_method = TRUE() ] ] )
Returns: Currency
Constraints: issue < first < settlement ; coupon > 0; par > 0
frequency is one of the following values:
Table 9 - ACCRINT
frequency Frequency of coupon payments
1 Annual
2 Semiannual
4 Quarterly
12 Monthly
Semantics: Calculates the accrued interest for securities with periodic interest payments. ACCRINT
supports short, standard, and long coupon periods.
If calc_method is TRUE (the default) then ACCRINT returns the sum of the accrued interest in each
coupon period from issue date until settlement date. If calc_method is FALSE then ACCRINT
returns the sum of the accrued interest in each coupon period from first date until settlement date.
For each coupon period, the interest is par*coupon*YEARFRAC(start-of-period;end-of-period; basis)
issue The security's issue or dated date.
first The security's first interest date.
settlement The security's settlement date.
coupon The security's annual coupon rate.
par The security's par value, that is, the principal to be paid at maturity.
frequency The number of coupon payments per year.
basis The type of day-count basis to use; see section 4.11.6
calc_method A logical value that specifies how to treat the case where settlement>first.
anchor:ACCRINT
Test Cases:
Expression Result Comments
=ACCRINT( 1992-12-01;
1993-06-01; 1993-07-01;
0.055; 100; 2; 0 )
3,208333
A bond has a December 1, 1992 issue date, a
June 1, 1993, first interest date, and a July 1,
1993, settlement date,. The semiannual coupon
rate is 5.50%. The bond has a $100 par value,
and a 30/360 day-count basis.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 147 of 442
=ACCRINT( 2001-02-28;
2001-08-31; 2001-05-01;
0.1; 1000; 2; 0 )
16,944444
A security is issued on 2.28.2001. First interest
is set for 8.31.2001. The settlement date is
5.1.2001. The Rate is 0.1 or 10% and Par is
1000 currency units. Interest is paid half-yearly
(frequency is 2). The basis is the US method
(0). How much interest has accrued?
=ACCRINT( 2004-02-01;
2004-04-01; 2004-05-01;
0.1; 1000; 4; 0 )
24.722222 leap year, quaterly, US (NASD) 30/360
=ACCRINT( 2004-02-01;
2004-04-01; 2004-05-01;
0.1; 1000; 4; 1 )
24.590164 leap year, quaterly, actual/acual
=ACCRINT( 2004-02-01;
2004-04-01; 2004-05-01;
0.1; 1000; 4; 2 )
25 leap year, quaterly, actual/360
=ACCRINT( 2004-02-01;
2004-04-01; 2004-05-01;
0.1; 1000; 4; 3 )
24.657534 leap year, quaterly, actual/365
=ACCRINT( 2004-02-01;
2004-04-01; 2004-05-01;
0.1; 1000; 4; 4 )
25 leap year, quaterly, European 30/360
=ACCRINT( 2004-02-01;
2004-04-01; 2004-05-01;
0.1; 1000; 1 )
24.722222 leap year, annual, US (NASD) 30/360
=ACCRINT( 2004-02-01;
2004-04-01; 2004-05-01;
0.1; 1000; 2 )
24.722222 leap year, semiannual, US 30/360
See also ACCRINTM
Note: This function has some divergent behavior in different implementations.
1-2-3 has a different parameter order: settlement;issue;first;coupon; par; frequency; basis.
Excel allows parameter par to be omitted in between, par and basis defaulted with values of 1000
and 0.
OpenOffice.org and Gnumeric allow a default value for basis only, with a value of 0.
Implementations usually don't support 12 as a valid value for frequency.
6.12.3 ACCRINTM
Summary: Calculates the accrued interest for securities that pay at maturity.
Syntax: ACCRINT( DateParam issue ; DateParam settlement ; Number coupon ; Number par [ ;
Basis basis = 0 ] )
Returns: Currency
Constraints: coupon > 0; par > 0
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 148 of 442
Semantics: Calculates the accrued interest for securities that pay at maturity.
issue The security's issue or dated date.
settlement The security's maturity date.
coupon The security's annual coupon rate.
par The security's par value, that is, the principal to be paid at maturity.
basis The type of day-count basis to use; see section 4.11.6
anchor:ACCRINTM
Test Cases:
Expression Result Comments
=ACCRINTM( DATE(2001;4
;1); DATE(2001;6;15); 0.1;
1000; 3 )
20,547945
=ACCRINTM( 2004-02-
01; 2004-05-01; 0.1;
1000; 0 )
24.722222 leap year, US (NASD) 30/360
=ACCRINTM( 2004-02-
01; 2004-05-01; 0.1;
1000; 1 )
24.590164 leap year, actual/actual
=ACCRINTM( 2004-02-
01; 2004-05-01; 0.1;
1000; 2 )
25 leap year, actual/360
=ACCRINTM( 2004-02-
01; 2004-05-01; 0.1;
1000; 3 )
24.657534 leap year, actual/365
=ACCRINTM( 2004-02-
01; 2004-05-01; 0.1;
1000; 4 )
25 leap year, European 30/360
See also ACCRINT
Note: Excel allows parameter par to be omitted in between, par and basis defaulted with values of
1000 and 0.
6.12.4 AMORDEGRC
Summary: Calculates the amortization value for the French accounting system using degressive
depreciation.
Syntax: AMORDEGRC( Number cost ; DateParam purchaseDate ; DateParam firstPeriodEndDate ;
Number salvage ; Integer period ; Number rate [ ; Basis basis = 0 ] )
Returns: Currency
Constraints: cost > 0; purchaseDate <= firstPeriodEndDate; salvage >= 0; period >= 0; rate > 0
Semantics: Calculates the amortization value for the French accounting system using degressive
depreciation.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 149 of 442
cost The value of the asset at the date of aquisition.
purchaseDate The date of aquisition.
firstPeriodEndDate The end date of the first depreciation period.
salvage The value of the asset at the end of the depreciation life time.
period The period of interest.
rate The rate of depreciation.
basis The type of day-count basis to use; see section 4.11.6
The asset life time is the inverse of the rate,
t =1/rate
. The depreciation factor is denoted by
factor.
Table 10 - AMORDEGRC
Asset life time (
t
) Depreciation factor (
factor
)
0t 3
1.0
3t 5
1.5
5t 6
2.0
t 6
2.5
The depreciation allowance for the period
p
is denoted by
DA
p
and takes the following values:
DA
0
=costratefactorYEARFRAC( purchaseDate , firstPeriodEndDate , basis )
DA
0pt 2
=ratefactorDA
p1
DA
t 2
=0.5DA
t 3
DA
t 1
=DA
t2
DA
pt
=0
anchor:AMORDEGRC
Test Cases:
Expression Result Comment
=AMORDEGRC( 1000; 2006-02-01;
2006-12-31; 10; 0; 0.1; 1 )
228 the first period (10 years life time)
=AMORDEGRC( 1000; 2006-02-01;
2006-12-31; 10; 8; 0.1; 1 )
52 the period before last (10 years)
=AMORDEGRC( 1000; 2006-02-01;
2006-12-31; 10; 9; 0.1; 1 )
52 the last period (10 years life time)
=AMORDEGRC( 1000; 2006-02-01;
2006-12-31; 10; 10; 0.1; 1 )
0 beyond life time (10 years life time)
=AMORDEGRC( 1000; 2006-02-01;
2006-12-31; 10; 0; 0.25; 1 )
342 the first period (4 years life time)
=AMORDEGRC( 1000; 2004-02-01; 229 leap year, US (NASD) 30/360
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 150 of 442
2006-12-31; 10; 0; 0.1; 0 )
=AMORDEGRC( 1000; 2004-02-01;
2006-12-31; 10; 0; 0.1; 1 )
228 leap year, actual/actual
=AMORDEGRC( 1000; 2004-02-01;
2006-12-31; 10; 0; 0.1; 2 )
232 leap year, actual/360
=AMORDEGRC( 1000; 2004-02-01;
2006-12-31; 10; 0; 0.1; 3 )
229 leap year, actual/365
=AMORDEGRC( 1000; 2004-02-01;
2006-12-31; 10; 0; 0.1; 4 )
228 leap year, European 30/360
See also AMORLINC , DB, DDB, YEARFRAC
6.12.5 AMORLINC
Summary: Calculates the amortization value for the French accounting system using linear
depreciation (l'amortissement linaire comptable) .
Syntax: AMORLINC( Number cost ; DateParam purchaseDate ; DateParam firstPeriodEndDate ;
Number salvage ; Integer period ; Number rate [ ; Basis basis = 0 ] )
Returns: Currency
Constraints: cost > 0; purchaseDate <= firstPeriodEndDate; salvage >= 0; period >= 0; rate > 0
Semantics: Calculates the amortization value for the French accounting system using linear
depreciation.
cost The value of the asset at the date of aquisition.
purchaseDate The date of aquisition.
firstPeriodEndDate The end date of the first depreciation period.
salvage The value of the asset at the end of the depreciation life time.
period Which period the depreciation should be calculated for.
rate The rate of depreciation.
basis Indicates the day count basis to use; see section 4.11.6
When period = 0:
AMORLINC=costrateYEARFRAC( purchaseDate , firstPeriodEndDate , basis )
For full periods, where period > 0, the depreciation is cost * rate
t=
cost salvage
costrate
For the last period, possibly a partial period, the depreciation = cost-salvage-accumulated-
depreciation, where accumulated-depreciation is the sum of the depreciation in period 0 plus any full
period depreciations.
AMORLINC=costrate
When period > depreciated life of the asset, i.e., when period > (cost-salvage)/(cost*rate) then the
depreciation is 0.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 151 of 442
AMORLINC=0
Note: The behavior of this function is implementation-defined in cases where purchaseDate =
firstPeriodEndDate.
anchor:AMORLINC
Test Cases:
Expression Result Comment
=AMORLINC(1000;DATE(2004;2;1);
DATE(2004;12;31);10;0;0.1;1)
91.256831 the first period (10 years life time)
=AMORLINC(1000;DATE(2004;2;1);
DATE(2004;12;31);10;8;0.1;1)
100 the period before last (10 years)
=AMORLINC(1000;DATE(2004;2;1);
DATE(2004;12;31);10;9;0.1;1)
98.743169 the last period (10 years life time)
=AMORLINC(1000;DATE(2004;2;1);
DATE(2004;12;31);10;10;0.1;1)
0 beyond life time (10 years life time)
=AMORLINC(1000;DATE(2004;2;1);
DATE(2004;12;31);10;0;0.25;1)
248,142076 the first period (4 years life time)
=AMORLINC(1000;DATE(2004;2;1);
DATE(2006;12;31);10;0;0.1;0)
91.666667 leap year, US (NASD) 30/360
=AMORLINC(1000;DATE(2004;2;1);
DATE(2006;12;31);10;0;0.1;2)
92.777778 leap year, actual/360
=AMORLINC(1000;DATE(2004;2;1);
DATE(2006;12;31);10;0;0.1;3)
91.506849 leap year, actual/365
=AMORLINC(1000;DATE(2004;2;1);
DATE(2006;12;31);10;0;0.1;4)
91.388889 leap year, European 30/360
See also AMORDEGRC, DB, DDB, YEARFRAC
6.12.6 COUPDAYBS
Summary: Calculates the number of days between the beginning of the coupon period that
contains the settlement date and the settlement date.
Syntax: COUPDAYBS( DateParam settlement ; DateParam maturity ; Integer frequency [ ; Basis
basis = 0 ] )
Returns: Number
Constraints: settlement < maturity
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 152 of 442
frequency is one of the following values:
Table 11 - COUPDAYBS
frequency Frequency of coupon payments
1 Annual
2 Semiannual
4 Quarterly
Semantics: Calculate the number of days from the beginning of the coupon period to the settlement
date.
settlement The settlement date.
maturity The maturity date.
frequency The number of coupon payments per year.
basis The type of day-count basis; see section 4.11.6
anchor:COUPDAYBS
Test Cases:
Expression Result Comments
COUPDAYBS( DATE(1997;11;9);
DATE(1999;11;15); 2 )
174
COUPDAYBS( DATE(1997;11;9);
DATE(1999;11;15); 2; 1 )
178
=COUPDAYBS( DATE(2004;3;1);
DATE(2009;1;1); 4; 0 )
60 US (NASD) 30/360
=COUPDAYBS( DATE(2004;3;1);
DATE(2009;1;1); 4; 1 )
60 actual/actual
=COUPDAYBS( DATE(2004;3;1);
DATE(2009;1;1); 4; 2 )
60 actual/360
=COUPDAYBS( DATE(2004;3;1);
DATE(2009;1;1); 4; 3 )
60 actual/365
=COUPDAYBS( DATE(2004;3;1);
DATE(2009;1;1); 4; 4 )
60 European 30/360
=COUPDAYBS( DATE(2004;3;1);
DATE(2009;1;1); 1 )
60 annual
=COUPDAYBS( DATE(2004;3;1);
DATE(2009;1;1); 2 )
60 semiannual
See also COUPDAYS , COUPDAYSNC , COUPNCD , COUPNUM , COUPPCD
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 153 of 442
6.12.7 COUPDAYS
Summary: Calculates the number of days in a coupon period that contains a settlement date.
Syntax: COUPDAYS( DateParam settlement ; DateParam maturity ; Integer frequency [ ; Basis
basis = 0 ] )
Returns: Number
Constraints: settlement < maturity
frequency is one of the following values:
Table 12 - COUPDAYS
frequency Frequency of coupon payments
1 Annual
2 Semiannual
4 Quarterly
Semantics: Calculates the number of days in the coupon period containing the settlement date.
settlement The settlement date.
maturity The maturity date.
frequency The number of coupon payments per year.
basis The type of day-count basis; see section 4.11.6
anchor:COUPDAYS
Test Cases:
Expression Result Comments
=COUPDAYS( DATE(1997;11;9);
DATE(1999;11;15); 2 )
180
=COUPDAYS( DATE(1997;11;9);
DATE(1999;11;15); 2; 1 )
184
=COUPDAYS( DATE(2004;2;1);
DATE(2009;1;1); 4; 0 )
90 US (NASD) 30/360
=COUPDAYS( DATE(2004;2;1);
DATE(2009;1;1); 4; 1 )
91 actual/actual
=COUPDAYS( DATE(2004;2;1);
DATE(2009;1;1); 4; 2 )
90 actual/360
=COUPDAYS( DATE(2004;2;1);
DATE(2009;1;1); 4; 3 )
91,25 actual/365
=COUPDAYS( DATE(2004;2;1);
DATE(2009;1;1); 4; 4 )
90 European 30/360
=COUPDAYS( DATE(2004;2;1);
DATE(2009;1;1); 1 )
360 annual
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 154 of 442
=COUPDAYS( DATE(2004;2;1);
DATE(2009;1;1); 2 )
180 semiannual
See also COUPDAYBS , COUPDAYSNC , COUPNCD , COUPNUM , COUPPCD
6.12.8 COUPDAYSNC
Summary: Calculates the number of days between a settlement date and the next coupon date.
Syntax: COUPDAYNC( DateParam settlement ; DateParam maturity ; Integer frequency [ ; Basis
basis = 0 ] )
Returns: Number
Constraints: settlement < maturity
frequency is one of the following values:
Table 13 - COUPDAYSNC
frequency Frequency of coupon payments
1 Annual
2 Semiannual
4 Quarterly
Semantics: Calculates the number of days between the settlement date and the next coupon date.
settlement The settlement date.
maturity The maturity date.
frequency The number of coupon payments per year.
basis The type of day-count basis; see section 4.11.6
anchor:COUPDAYSNC
Test Cases:
Expression Result Comments
=COUPDAYSNC( DATE(1997;5;
19); DATE(1999;11;15); 2 )
176
=COUPDAYSNC( DATE(1997;5;
19); DATE(1999;11;15); 2; 1 )
180
=COUPDAYSNC( DATE(2004;2;
1); DATE(2009;1;1); 4; 0 )
60
=COUPDAYSNC( DATE(2004;2;
1); DATE(2009;1;1); 4; 1 )
60
=COUPDAYSNC( DATE(2004;2;
1); DATE(2009;1;1); 4; 2 )
60
=COUPDAYSNC( DATE(2004;2; 60
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 155 of 442
1); DATE(2009;1;1); 4; 3 )
=COUPDAYSNC( DATE(2004;2;
1); DATE(2009;1;1); 4; 4 )
60
=COUPDAYSNC( DATE(2004;2;
1); DATE(2009;1;1); 1 )
330 annual
=COUPDAYSNC( DATE(2004;2;
1); DATE(2009;1;1); 2 )
150 semiannual
See also COUPDAYBS , COUPDAYS , COUPNCD , COUPNUM , COUPPCD
6.12.9 COUPNCD
Summary: Calculates the next coupon date following a settlement.
Syntax: COUPNCD( DateParam settlement ; DateParam maturity ; Integer frequency [ ; Basis
basis = 0 ] )
Returns: Date
Constraints: settlement < maturity
frequency is the number of coupon payments per year. frequency is one of the following values:
Table 14 - COUPNCD
frequency Frequency of coupon payments
1 Annual
2 Semiannual
4 Quarterly
Semantics: Calculates the next coupon date after the settlement date based on the maturity
(expiration) date of the asset, the frequency of coupon payments and the day-count basis.
anchor:COUPNCD
Test Cases:
Expression Result Comment
=COUPNCD( 2004-01-01; 2007-01-
01; 1; 1 )=DATE(2005;01;01)
True Annual
=COUPNCD( 2004-01-01; 2007-01-
01; 2; 1 )=DATE(2004;07;01)
True Semiannual
=COUPNCD( 2004-01-01; 2007-01-
01; 4; 1 )=DATE(2004;04;01)
True Quarterly
=COUPNCD( 2007-01-01; 2007-01-
01; 1; 1 )
Error settlement < maturity
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 156 of 442
=COUPNCD( 2004-01-01; 2009-01-
01; 4; 0 )=DATE(2004;04;01)
True
=COUPNCD( 2004-01-01; 2009-01-
01; 4; 1 )=DATE(2004;04;01)
True
=COUPNCD( 2004-01-01; 2009-01-
01; 4; 2 )=DATE(2004;04;01)
True
=COUPNCD( 2004-01-01; 2009-01-
01; 4; 3 )=DATE(2004;04;01)
True
=COUPNCD( 2004-01-01; 2009-01-
01; 4; 4 )=DATE(2004;04;01)
True
6.12.10 COUPNUM
Summary: Calculates the number of outstanding coupons between settlement and maturity dates.
Syntax: COUPNUM( DateParam settlement ; DateParam maturity ; Integer frequency [ ; Basis
basis = 0 ] )
Returns: Number
Constraints: frequency is the number of coupon payments per year. frequency is one of the
following values:
Table 15 - COUPNUM
frequency Frequency of coupon payments
1 Annual
2 Semiannual
4 Quarterly
Semantics: Calculates the number of coupons in the interval between the settlement and the
maturity (expiration) date of the asset, the frequency of coupon payments and the day-count basis.
anchor:COUPNUM
Test Cases:
Expression Result Comment
=COUPNUM( 2004-01-01; 2007-01-
01; 1; 1 )
3 Annual
=COUPNUM( 2004-01-01; 2007-01-
01; 2; 1 )
6 Semiannual
=COUPNUM( 2004-01-01; 2007-01-
01; 4; 1 )
12 Quarterly
=COUPNUM( 2004-02-01; 2009-01- 20
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 157 of 442
01; 4; 0 )
=COUPNUM( 2004-02-01; 2009-01-
01; 4; 1 )
20
=COUPNUM( 2004-02-01; 2009-01-
01; 4; 2 )
20
=COUPNUM( 2004-02-01; 2009-01-
01; 4; 3 )
20
=COUPNUM( 2004-02-01; 2009-01-
01; 4; 4 )
20
See also COUPDAYBS, COUPDAYS, COUPDAYSNC, COUPNCD, COUPPCD
6.12.11 COUPPCD
Summary: Calculates the next coupon date prior a settlement.
Syntax: COUPPCD( DateParam settlement ; DateParam maturity ; Integer frequency [ ; Basis basis
= 0 ] )
Returns: Date
Constraints: settlement < maturity
frequency is the number of coupon payments per year. frequency is one of the following values:
Table 16 - COUPPCD
frequency Frequency of coupon payments
1 Annual
2 Semiannual
4 Quarterly
Semantics: Calculates the next coupon date prior to the settlement date based on the maturity
(expiration) date of the asset, the frequency of coupon payments and the day-count basis.
anchor:COUPPCD
Test Cases:
Expression Result Comment
=COUPPCD( 2004-12-31; 2007-01-
01; 1; 1 )=DATE(2004;1;1)
True Annual
=COUPPCD( 2004-12-31; 2007-01-
01; 2; 1 )=DATE(2004;1;7)
True Semiannual
=COUPPCD( 2004-12-31; 2007-01-
01; 4; 1 )=DATE(2004;1;1)
True Quarterly
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 158 of 442
=COUPPCD( 2007-01-01; 2004-01-
01; 1; 1 )
Error settlement < maturity
=COUPPCD( 2004-02-29; 2009-01-
01; 4; 0 )=DATE(2004;01;01)
True
=COUPPCD( 2004-02-29; 2009-01-
01; 4; 1 )=DATE(2004;01;01)
True
=COUPPCD( 2004-02-29; 2009-01-
01; 4; 2 )=DATE(2004;01;01)
True
=COUPPCD( 2004-02-29; 2009-01-
01; 4; 3 )=DATE(2004;01;01)
True
=COUPPCD( 2004-02-29; 2009-01-
01; 4; 4 )=DATE(2004;01;01)
Ture
See also COUPDAYBS, COUPDAYS, COUPDAYSNC, COUPNCD, COUPNUM
6.12.12 CUMIPMT
Summary: Calculates a cumulative interest payment.
Syntax: CUMIPMT( Number rate ; Number periods ; Number value ; Integer start ; Integer end ;
Integer type )
Returns: Currency
Constraints: rate > 0; value > 0; 1 <= start <= end <= periods
type is one of the following values:
Table 17 - CUMIPMT
type Maturity date
0 due at the end
1 due at the beginning
Semantics: Calculates the cumulative interest payment.
rate The interest rate per period.
periods The number of periods.
value The current value of the loan.
start The starting period.
end The end period.
type The maturity date, the beginning or the end of a period.
CUMIPMT=
p=start
end
IPMT(rate , p , periods , value , 0, type)
anchor:CUMIPMT
Test Cases:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 159 of 442
Expression Result Comment
=CUMIPMT( 0.06/12; 5*12; 100000; 5;
12; 0 )
-3562,187023 maturity at the end of a period
=CUMIPMT( 0.06/12; 5*12; 100000; 5;
12; 1 )
-3544,464699 maturity at the beginning of a period
=CUMIPMT( 0.06/12; 5*12; 100000; 0;
0; 0 )
Error start > 0; end > 0
=CUMIPMT( 0.06/12; 5*12; 100000; 5;
61; 0 )
Error end > periods
=CUMIPMT( 0.06/12; 5*12; 100000; 15;
12; 0 )
Error start > end
See also IPMT, CUMPRINC
6.12.13 CUMPRINC
Summary: Calculates a cumulative principal payment.
Syntax: CUMPRINC( Number rate ; Number periods ; Number value ; Integer start ; Integer end ;
Integer type )
Returns: Currency
Constraints: type is one of the following values:
Table 18 - CUMPRINC
type Maturity date
0 due at the end
1 due at the beginning
Semantics: Calculates the cumulative principal payment.
rate The interest rate per period.
periods The number of periods.
value The current value of the loan.
start The starting period.
end The end period.
type The maturity date, the beginning or the end of a period.
CUMPRINC=
p=start
end
PPMT(rate , p , periods, value , 0, type)
anchor:CUMPRINC
Test Cases:
Expression Result Comment
=CUMPRINC( 0.06/12; 5*12; 100000; - maturity at the end of a period
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 160 of 442
5; 12; 0 )
11904,054201
(
1
(
1
month
12
)
rate
)
The depreciation allowance for the first period is
DB
1
=costvalue
1
For all other periods the allowance is calculated by
DB
period
=value
period
value
period1
For all periods, where period > lifeTime + 1 INT(month/12), the depreciation allowance is zero.
anchor:DB
Test Cases:
Expression Result Comment
=DB(4000;500;4;2) 963.90 An example of DB.
=DB(4000;500;4;2;2) 1510.65 Default month is 12.
=DB(4000;500;4;5) 0 If period > lifetime, return zero.
=DB(0;500;4;2) Error cost > 0
=DB(4000;-500;4;2) Error salvage >= 0
=DB(4000;500;0;0) Error lifeTime > 0
=DB(4000;500;2;0) Error period > 0
See also DDB, SLN
Rationale: A depreciation of an asset with no value is senseless. Thus, an Error is returned, if the
initial value, cost, is zero.
6.12.15 DDB
Summary: Compute the amount of depreciation at a given period of time.
Syntax: DDB( Number cost ; Number salvage ; Number lifeTime ; Number period [ ; Number
declinationFactor = 2 ] )
Returns: Currency
Constraints: cost >= 0, salvage >= 0, salvage <= cost, 1 <= period <= lifeTime, declinationFactor >
0
Semantics: Compute the amount of depreciation of an asset at a given period of time. The
parameters are:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 162 of 442
cost: the total amount paid for the asset.
salvage: the salvage value at the end of the LifeTime
lifeTime: the number of periods that the depreciation will occur over.
period: the period for which a depreciation value is specified.
declinationFactor: the method of calculating depreciation, the rate at which the balance
declines. Defaults to 2. If 2, double-declining balance is used.
To calculate depreciation, DDB uses a fixed rate. When declinationFactor = 2 this is the double-
declining-balance method (because it is double the straight-line rate that would depreciate the asset
to zero). The rate is given by:
rate=
declinationFactor
lifeTime
The depreciation each period is calculated as
depreciation_of_period = MIN( book_value_at_start_of_ period * rate; book_value_at_start_of_
period - salvage )
Thus the asset depreciates at rate until the book value is salvage value.
BookValueAtStartOfPeriod
p
= cost
i =1
p1
DepreciationOfPeriod
i
To allow also non-integer period values this algorithm may be used:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 163 of 442
rate=
declinationFactor
lifeTime
if rate1 then
{
rate=1
if period=1 then
oldValue=cost
else
oldValue=0
endif
}
else
{
oldValue=cost(1rate)
period 1
}
endif
newValue=cost(1rate)
period
if newValuesalvage then
DDB=oldValuesalvage
else
DDB=oldValuenewValue
endif
if DDB0 then
DDB=0
endif
If period is an Integer number, the relation between DDB and VDB is:
DDB( cost ; salvage ; lifeTime ; period ; declinationFactor )
equals
VDB( cost ; salvage ; lifeTime ; period - 1 ; period ; declinationFactor ; TRUE() )
anchor:DDB
Test Cases:
Expression Result Comment
=DDB(4000;500;4;2) 1000 A trivial example of DDB.
=DDB(4000;500;4;2;2) 1000 Default method is 2 (double declining balance).
=DDB( 1100; 100; 5; 5;
2.3 )
0 Some applications create negative values here.
See also SLN, VDB
6.12.16 DISC
Summary: Returns the discount rate of a security.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 164 of 442
Syntax: DISC( DateParam settlement ; DateParam maturity ; Number price ; Number redemption [ ;
Basis basis = 0 ] )
Returns: Percentage
Constraints: settlement < maturity
Semantics: Calculates the discount rate of a security.
settlement The settlement date of the security.
maturity The maturity date.
price The price of the security.
redemption The redemption value of the security.
basis The day-count basis; see section 4.11.6
DISC=
redemptionprice
redemption
YEARFRAC( settlement , maturity , basis )
anchor:DISC
Test Cases:
Expression Result Comment
=DISC( 2004-02-29; 2009-01-01;
95000; 100000; 0 )
0.010339 US (NASD) 30/360
=DISC( 2004-02-29; 2009-01-01;
95000; 100000; 1 )
0.010333 actual/actual
=DISC( 2004-02-29; 2009-01-01;
95000; 100000; 2 )
0.010181 actual/360
=DISC( 2004-02-29; 2009-01-01;
95000; 100000; 3 )
0.010322 actual/365
=DISC( 2004-02-29; 2009-01-01;
95000; 100000; 4 )
0.010333 European 30/360
=DISC( 2006-01-01; 2008-01-01;
200; 100; 3 )
-0.5 negative discount
=DISC( 2006-01-01; 2005-07-01;
95000; 100000; 3 )
Error settlement < maturity
See also YEARFRAC
6.12.17 DOLLARDE
Summary: Converts a fractional dollar representation into a decimal representation.
Syntax: DOLLARDE( Number fractional ; Integer denominator )
Returns: Number
Constraints: denominator > 0
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 165 of 442
Semantics: Converts a fractional dollar representation into a decimal representation.
fractional Decimal fraction.
denominator Denominator of the fraction.
DOLLARDE=TRUNC( fractional)+
fractionalTRUNC( fractional)
denominator
anchor:DOLLARDE
Test Cases:
Expression Result Comment
=DOLLARDE( 1.1; 4 ) 1.25 rationale number
=DOLLARDE( 1.1; 3 ) 1.333333 irrational number
=DOLLARDE( -1.1; 10 ) -1.1 negative number
=DOLLARDE( 1.0; 5 ) 1 no fraction
=DOLLARDE( 1.1; 0 ) Error denominator > 0
See also DOLLARFR , TRUNC
6.12.18 DOLLARFR
Summary: Converts a decimal dollar representation into a fractional representation.
Syntax: DOLLARFR( Number decimal ; Integer denominator )
Returns: Number
Constraints: denominator > 0
Semantics: Converts a decimal dollar representation into a fractional representation.
decimal Decimal number.
denominator Denominator of the fraction.
DOLLARFR=TRUNC(decimal)+( decimalTRUNC(decimal))denominator
anchor:DOLLARFR
Test Cases:
Expression Result Comment
=DOLLARFR( 1.1; 10 ) 1.1 a denominator of 10 is actually useless
=DOLLARFR( 1.25; 4 ) 1.1
=DOLLARFR( -1.33333; 3 ) 1.099999
=DOLLARFR( 1.0; 5 ) 1 no fraction
=DOLLARFR( 1.1; 0 ) Error denominator > 0
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 166 of 442
See also DOLLARDE, TRUNC
6.12.19 DURATION
Summary: Returns the Macaulay duration of a fixed interest security in years
Syntax: DURATION( Date Settlement ; Date Maturity ; Number Coupon ; Number Yield ; Number
Frequency [ ; Basis Basis = 0 ] )
Returns: Number
Constraints: Yield >=0, Coupon >= 0, Settlement <= Maturity; Frequency = 1, 2, 4
Semantics: Computes the Macaulay duration, given:
Settlement the date of purchase of the security
Maturity the date when the security matures
Coupon the annual nominal rate of interest
Yield the annual yield of the security
Frequency number of interest payments per year
Basis Date calculation basis; see section 4.11.6
anchor:DURATION
Test Cases:
TODO: formula, test cases
Expression Result Comment
See also MDURATION
6.12.20 EFFECT
Summary: Returns the net annual interest rate for a nominal interest rate.
Syntax: EFFECT( Number rate ; Integer payments )
Returns: Number
Constraints: rate >= 0; payments > 0
Semantics: Nominal interest refers to the amount of interest due at the end of a calculation period.
Effective interest increases with the number of payments made. In other words, interest is often paid
in installments (for example, monthly or quarterly) before the end of the calculation period.
rate The interest rate per period.
payments The number of payments per period.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 167 of 442
EFFECT=
(
1+
rate
payments
)
payments
1
anchor:EFFECT
Test Cases:
Expression Result Comment
=EFFECT( 0.1; 12 ) 0.104713 monthly payment
=EFFECT( 0.1; 6 ) 0.104260 bimonthly payment
=EFFECT( 0.1; 2 ) 0.1025 semiannual payment
=EFFECT( 0; 12 ) Error rate > 0
=EFFECT( 0.1; 0 ) Error payments > 0
See also NOMINAL
Note: Two functions, EFFECTIVE and EFFECT_ADD, exist in Ooo Calc 2.1. Both calculate the
same result and have the same amount of parameters. They differ in the display format of the return
value only: EFFECTIVE displays Percentage, EFFECT_ADD displays Number. Both are to be
replaced by this EFFECT function here.
6.12.21 FV
Summary: Compute the future value (FV) of an investment.
Syntax: FV( Number Rate ; Number Nper ; Number Payment [ ; [ Number Pv = 0 ] [ ; Number
PayType = 0 ] ] )
Returns: Currency
Constraints: None.
Semantics: Computes the future value of an investment. The parameters are:
Rate: the interest rate per period.
Nper: the total number of payment periods.
Payment: the payment made in each period.
Pv: the present value; default is 0.
PayType: the type of payment, defaults to 0. It is 0 if payments are due at the end of the period;
1 if they are due at the beginning of the period.
See PV for the equation this solves.
anchor:FV
Test Cases:
Expression Result Comment
=FV(10%;12;-100;100) 1824.590.0 A trivial example of FV.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 168 of 442
1
See also PV, NPER, PMT, RATE
6.12.22 FVSCHEDULE
Summary: Returns the accumulated value given starting capital and a series of interest rates.
Syntax: FVSCHEDULE( Number Principal ; NumberSequence Schedule )
Returns: Currency
Constraints: None.
Semantics: Returns the accumulated value given starting capital and a series of interest rates, as
follows:
Principle
i=1
N
(1+Schedule | i )
anchor:FVSCHEDULE
Test Cases:
Expression Result Comment
=FVSCHEDULE(1000000; {0.03; 0.04; 0.05}) 1124760
A trivial example of
FVSCHEDULE.
See also PV, NPER, PMT, RATE
Note: The result for the test case has +/- even though the correct result is exact, because many
implementations will have inexact representations for some of these values.
6.12.23 INTRATE
Summary: Computes the interest rate of a fully vested security.
Syntax: INTRATE( Date Settlement ; Date Maturity ; Number Investment ; Number Redemption [ ;
Basis Basis = 0 ] )
Returns: Number
Constraints: Settlement < Maturity
Semantics: Calculates the annual interest rate that results when an item is purchased at the
investment price and sold at the redemption price. No interest is paid on the investment. The
parameters are:
Settlement: the date of purchase of the security.
Maturity: the date on which the security is sold.
Investment: the purchase price.
Redemption: the selling price.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 169 of 442
Basis: [optional] indicates the day count basis to use; see section 4.11.6.
The return value for this function is:
INTRATE=
RedemptionInvestment
Investment
YEARFRAC( Settlement ; Maturity ; Basis)
anchor:INTRATE
Test Cases:
Expression Result Comment
=INTRATE(DATE(2002;6;8);
DATE(1995;10;5); 100000; 200000;
0)
Error
Settlement date must be before the
maturity date.
=INTRATE(DATE(2002;6;8);
DATE(2002;6;8); 100000; 200000; 0)
Error
Settlement date must be before the
maturity date.
=INTRATE(DATE(1995;10;5);
DATE(2002;6;8); 100000; 200000;
50)
Error Unknown Basis returns Error.
=INTRATE(DATE(1995;10;5);
DATE(2002;6;8); 100000; 200000; 0)
0.14981 An example of INTRATE.
=INTRATE(DATE(1995;10;5);
DATE(2002;6;8); 100000; 200000)
0.14981 Basis defaults to 0.
=INTRATE(DATE(1995;10;5);
DATE(2002;6;8); 100000; 200000; 1)
0.14971
=INTRATE(DATE(1995;10;5);
DATE(2002;6;8); 100000; 200000; 2)
0.14766
=INTRATE(DATE(1995;10;5);
DATE(2002;6;8); 100000; 200000; 3)
0.14971
=INTRATE(DATE(1995;10;5);
DATE(2002;6;8); 100000; 200000; 4)
0.14981
See also RECEIVED, YEARFRAC
6.12.24 IPMT
Summary: Returns the amount of an annuity payment going towards interest.
Syntax: IPMT( Number Rate ; Number Period ; Number Nper ; Number PV [ ; Number FV = 0 [ ;
Number Type = 0 ] ] )
Returns: Currency
Constraints: None.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 170 of 442
Semantics: Computes the interest portion of an amortized payment for a constant interest rate and
regular payments. The interest payment is the interest rate multiplied by the balance at the
beginning of the period. The parameters are:
Rate: The periodic interest rate.
Period: The period for which the interest payment is computed.
Nper: The total number of periods for which the payments are made
PV: The present value (e.g. The initial loan amount).
FV: The future value (optional) at the end of the periods. Zero if omitted.
Type: the due date for the payments (optional). Zero if omitted. If type is 1, then payments
are made at the beginning of each period. If type is 0, then payments are made at the end
of each period.
anchor:IPMT
Test Cases:
Expression Result Comment
=IPMT(5%/12;10;360;100000) -412.0850243
An example of IPMT. The interest
payment on a 100000 unit loan in the
10
th
month of a 30 year loan at 5%
annual interest.
=IPMT(5%/12;10;360;100000;0;1) -410.375128
Payments at the beginning of each
period.
See also PPMT, PMT
6.12.25 IRR
Summary: Compute the internal rate of return for a series of cash flows.
Syntax: IRR( NumberSequence Values [ ; Number Guess = 0.1 ] )
Returns: Percentage
Constraints: None.
Semantics: Compute the internal rate of return for a series of cash flows.
If provided, Guess is an estimate of the interest rate to start the iterative computation. If omitted, the
value 0.1 (10%) is assumed.
The result of IRR is the rate at which the NPV() function will return zero with the given values.
There is no closed form for IRR. Evaluators may return an approximate solution using an iterative
method, in which case the Guess parameter may be used to initialize the iteration. If the evaluator is
unable to converge on a solution given a particular Guess, it may return an Error.
anchor:IRR
Test Cases:
Expression Result Comment
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 171 of 442
=IRR([.F24:.F26])
0.41878700
01653411e
-5
A trivial example of IRR.
See also NPV, RATE
6.12.26 ISPMT
Summary: Compute the interest payment of an amortized loan for a given period.
Syntax: ISPMT( Number Rate ; Number Period ; Number Nper ; Number Pv )
Returns: Currency
Constraints: None.
Semantics: Computes the interest payment of an amortized loan for a given period. The
parameters are:
Rate: the interest rate per period.
Period: the period for which the interest is computed
Nper: the total number of payment periods.
Pv: the amount of the investment
anchor:ISPMT
Test Cases:
Expression Result Comment
=ISPMT(5%/12;12;360;100000) -402.780.01
A trivial example of ISPMT. A
100000 unit investment with an
annual interest rate of 5% and a 30
year term has an interest payment
of 402.78 units in month 12.
See also PV, FV, NPER, PMT, RATE
6.12.27 MDURATION
Summary: Returns the modified Macaulay duration of a fixed interest security in years
Syntax: MDURATION( Date Settlement ; Date Maturity ; Number Coupon ; Number Yield ; Number
Frequency [ ; Basis Basis = 0 ] )
Returns: Number
Constraints: Yield >= 0, Coupon >= 0, Settlement <= Maturity; Frequency = 1, 2, 4
Semantics: Computes the modified Macaulay duration, given:
Settlement the date of purchase of the security
Maturity the date when the security matures
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 172 of 442
Coupon the annual nominal rate of interest
Yield the annual yield of the security
Frequency number of interest payments per year
Basis Date calculation basis; see section 4.11.6
The modified duration is computed as follows:
duration=DURATION ( Settlement , Maturity ,Coupon , Yield , Frequency , Basis )
MDURATION =
duration
1+
(
Yield
Frequency
)
anchor:MDURATION
Test Cases:
Expression Result Comment
=MDURATION(DATE(2004;2;1);
DATE(2004;5;31); 0.08; 0.09; 2; 0)
0.316321106
These tests go over a leap year
day, and intentionally end on May
31, which illustrates the differences
between many bases
=MDURATION(DATE(2004;2;1);
DATE(2004;5;31); 0.08; 0.09; 2; 1)
0.313750098
=MDURATION(DATE(2004;2;1);
DATE(2004;5;31); 0.08; 0.09; 2; 2)
0.311004785
=MDURATION(DATE(2004;2;1);
DATE(2004;5;31); 0.08; 0.09; 2; 3)
0.313298814 Note slight difference from basis 1
=MDURATION(DATE(2004;2;1);
DATE(2004;5;31); 0.08; 0.09; 2; 4)
0.316321106
Basis 4 and 0 are the same in this
case
=MDURATION(DATE(2004;5;31);
DATE(2004;6;1); 0.08; 0.09; 2; 0)
0
Basis 0 system; a start date of
2004-05-31 is moved to next day,
resulting in 0 duration
=MDURATION(DATE(2004;5;31);
DATE(2004;6;1); 0.08; 0.09; 2; 4)
0.002658161
Basis 4 system differs from basis 0
in this case
See also DURATION
6.12.28 MIRR
Summary: Returns the modified internal rate of return (IRR) of a series of periodic investments
Syntax: MIRR( Array Values ; Number Investment ; Number ReinvestRate )
Returns: Percentage
Constraints: Values shall contain at least one positive value and at least one negative value.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 173 of 442
Semantics: Values is a series of periodic income (positive values) and payments (negative values)
at regular intervals (Text and Empty cells are ignored). Investment is the rate of interest of the
payments (negative values); ReinvestRate is the rate of interest of the reinvestment (positive
values).
Computes the modified internal rate of return, which is:
(
NPV ( ReinvestRate , Values>0)( 1+ReinvestRate)
n
NPV ( Investment ; Values0)( 1+Investment )
)
(
1
n 1
)
1
where N is the number of incomes and payments in Values (total).
anchor:MIRR
Test Cases:
Expression Result Comment
=MIRR({100;200;-50;300;-200}, 5%,
6%)
0.342823387842
See also IRR
6.12.29 NOMINAL
Summary: Compute the annual nominal interest rate.
Syntax: NOMINAL( Number EffectiveRate ; Integer CompoundingPeriods )
Returns: Number
Constraints: EffectiveRate >0 , CompoundingPeriods > 0
Semantics: Returns the annual nominal interest rate based on the effective rate and the number of
compounding periods in one year. The parameters are:
EffectiveRate: effective rate
CompoundingPeriods: the compounding periods per year
Suppose that P is the present value, m is the compounding periods per year, the future value after
one year is
P
(
1+
NOMINAL
m
)
m
The mapping between nominal rate and effective rate is
EFFECT=
(
1+
NOMINAL
m
)
m
1
anchor:NOMINAL
Test Cases:
Expression Result Comment
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 174 of 442
=NOMINAL(8%;4) 0.077706187633
=NOMINAL(12.5%;12) 0.118362966639
=NOMINAL(1%;2) 0.004993765576
See also EFFECT
Note: Two functions, NOMINAL and NOMINAL_ADD, exist in Ooo Calc 2.1. Both calculate the
same result and have the same amount of parameters. They differ in the display format of the return
value only: NOMINAL displays Percentage, NOMINAL_ADD displays Number. Both are to be
replaced by this NOMINAL function here.
6.12.30 NPER
Summary: Compute the number of payment periods for an investment.
Syntax: NPER( Number Rate ; Number Payment ; Number Pv [ ; [ Number Fv ] [ ; Number
PayType ] ] )
Returns: Number
Constraints: None.
Semantics: Computes the number of payment periods for an investment. The parameters are:
Rate: the constant interest rate.
Payment: the payment made in each period.
Pv: the present value of the investment.
Fv: the future value; default is 0.
PayType: the type of payment, defaults to 0. It is 0 if payments are due at the end of the period;
1 if they are due at the beginning of the period.
If Rate is 0, then NPER solves this equation:
Pv =Fv( PaymentNPER)
If Rate is non-zero, then NPER solves this equation:
0 = Pv(1+Rate)
NPER
+
Payment(1+RatePaymentType)((1+Rate)
NPER
1)
Rate
+Fv
Evaluators claiming to support the Medium or Large set shall support negative rates; evaluators
only claiming to support the Small set need not.
anchor:NPER
Test Cases:
Expression Result Comment
=NPER(5%;-100;1000)
14.20670.
001
A trivial example of NPER.
=NPER(5%;-100;1000;100) 15.20670. A trivial example of NPER with non-zero FV.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 175 of 442
001
=NPER(5%;-100;1000;100;1)
14.20670.
001
A trivial example of NPER with non-zero FV
and PayType.
=NPER(0;-100;1000) 10 Rate can be zero.
=NPER(-1%;-100;1000)
9.48328306
60.001
Rate can be negative.
Note: Gnumeric gives an Error for negative rates. Excel and OOo2 do not. For NPER(-1%;-
100;1000), OOo2 gives 9.48, Excel produces 9.483283066, Gnumeric gives a #DIV/0 Error. This
appears to be a bug in Gnumeric.
See also FV, RATE, PMT, PV
6.12.31 NPV
Summary: Compute the net present value (NPV) for a series of periodic cash flows.
Syntax: NPV( Number Rate ; { NumberSequenceList Value }
+
)
Returns: Currency
Constraints: None.
Semantics: Computes the net present value for a series of periodic cash flows with the discount
rate Rate. Values should be positive if they are received as income, and negative if the amounts are
paid as outgo. Because the result is affected by the order of values, evaluators shall evaluate
arguments in the order given and range reference and array arguments row-wise starting from top
left.
If n is the number of values in the Values, the formula for NPV is:
NPV =
i=1
N
Values
i
( 1+Rate)
i
anchor:NPV
Test Cases:
Expression Result Comment
=NPV(100%;4;5;7) 4.125 A trivial example of NPV
=NPV(100%;[.C4:.C6]) 4.125
Note that each number in a range is
considered separately.
=NPV(10%;100;200)
256.198347
1074380.0
01
A more interesting value.
See also FV, IRR, NPER, PMT, PV, XNPV
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 176 of 442
6.12.32 ODDFPRICE
Summary: Compute the value of a security per 100 currency units of face value. The security has
an irregular first interest date.
Syntax: ODDFPRICE( DateParam Settlement ; DateParam Maturity ; DateParam Issue ;
DateParam First ; Number Rate ; Number Yield ; Number Redemption ; Number Frequency [ ; Basis
Basis = 0 ] )
Returns: Number
Constraints: Rate, Yield, and Redemption should be greater than 0.
Semantics: The parameters are
Settlement: the settlement/purchase date of the security
Maturity: the maturity/expire date of the security
Issue: the issue date of the security
First: the first coupon date of the security
Rate: the interest rate of the security
Yield: the annual yield of the security
Redemption: the redemption value per 100 currency units face value
Frequency: the number of interest payments per year. 1=annual; 2=half-yearly; 4=quarterly.
Basis: the type which indicates how the year is to be calculated by days; see section 4.11.6.
anchor:ODDFPRICE
Test Cases:
Note: It seems that OpenOffice.org 2.0 can not return any valid result. The following cases use the
result of Excel.
Expression Result Comment
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);10%;5%;100;2)
123.959071625 Without Basis parameter
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);10%;5%;100;2;0)
123.959071625
With Frequency=2 and
Basis=0
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);10%;5%;100;4;0)
124.051999184
With Frequency=4 and
Basis=0
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;5%;1000;1;1)
790.113232219
With Frequency=1 and
Basis=1
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;5%;1000;2;1)
787.959637188
With Frequency=2 and
Basis=1
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 177 of 442
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;5%;1000;4;1)
786.814617900
With Frequency=4 and
Basis=1
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;3.5%;1000;1;2)
825.983477953
With Frequency=1 and
Basis=2
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;3.5%;1000;2;2)
854.085502820
With Frequency=2 and
Basis=2
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;3.5%;1000;4;2)
853.464549056
With Frequency=4 and
Basis=2
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;3.5%;1000;1;3)
855.173129165
With Frequency=1 and
Basis=3
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;3.5%;1000;2;3)
854.112498430
With Frequency=2 and
Basis=3
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;3.5%;1000;4;3)
853.512251235
With Frequency=4 and
Basis=3
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);15%;3.5%;1000;1;4)
875.190231860
With Frequency=1 and
Basis=4
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);15%;3.5%;1000;2;4)
874.167959918
With Frequency=2 and
Basis=4
=ODDFPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);15%;3.5%;1000;4;4)
873.648594549
With Frequency=4 and
Basis=4
See also ODDLPRICE , ODDFYIELD
6.12.33 ODDFYIELD
Summary: Compute the yield of a security per 100 currency units of face value. The security has an
irregular first interest date.
Syntax: ODDFYIELD( DateParam Settlement ; DateParam Maturity ; DateParam Issue ;
DateParam First ; Number Rate ; Number Price ; Number Redemption ; Number Frequency [ ;
Basis Basis = 0 ] )
Returns: Number
Constraints: Rate, Price, and Redemption should be greater than 0. Maturity > First > Settlement >
Issue.
Semantics: The parameters are
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 178 of 442
Settlement: the settlement/purchase date of the security
Maturity: the maturity/expire date of the security
Issue: the issue date of the security
First: the first coupon date of the security
Rate: the interest rate of the security
Price: the price of the security
Redemption: the redemption value per 100 currency units face value
Frequency: the number of interest payments per year. 1=annual; 2=half-yearly; 4=quarterly.
Basis: the type which indicates how the year is to be calculated by days; see section 4.11.6
anchor:ODDFYIELD
Test Cases:
Note: It seems that OpenOffice.org 2.0 can not return any valid result. The following cases use the
result of Excel.
Expression Result Comment
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);10%;124;100;2)
4.992596833% Without Basis parameter
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);10%;124;100;2;0)
4.992596833%
With Frequency=2 and
Basis=0
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);10%;124;100;4;0)
5.009384625%
With Frequency=4 and
Basis=0
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;790;100;1;1)
5.002737530%
With Frequency=1 and
Basis=1
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;788;100;2;1)
4.999042749%
With Frequency=2 and
Basis=1
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;787;100;4;1)
4.995647116%
With Frequency=4 and
Basis=1
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);DATE(1990
;12;31);6%;826;1000;1;2)
3.499682116%
With Frequency=1 and
Basis=2
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1),DATE(1990
;12;31);6%;854;2;2)
3.501855575%
With Frequency=2 and
Basis=2
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1),DATE(1990
3.488467062% With Frequency=4 and
Basis=2
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 179 of 442
;12;31);6%;854;4;2)
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1),DATE(1990
;12;31);6%;855;1;3)
3.503809321%
With Frequency=1 and
Basis=3
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1),DATE(1990
;12;31);6%;854;2;3)
3.502441884%
With Frequency=2 and
Basis=3
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1),DATE(1990
;12;31);6%;854;4;3)
3.489492455%
With Frequency=4 and
Basis=3
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1),DATE(1990
;12;31);15%;875;1;4)
4.045647929%
With Frequency=1 and
Basis=4
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1),DATE(1990
;12;31);15%;874;2;4)
4.041480570%
With Frequency=2 and
Basis=4
=ODDFYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1),DATE(1990
;12;31);15%;874;4;4)
4.028403919%
With Frequency=4 and
Basis=4
See also ODDLYIELD , ODDFPRICE
6.12.34 ODDLPRICE
Summary: Compute the value of a security per 100 currency units of face value. The security has
an irregular last interest date.
Syntax: ODDLPRICE( DateParam Settlement ; DateParam Maturity ; DateParam Last ; Number
Rate ; Number AnnualYield ; Number Redemption ; Number Frequency [ ; Basis Basis = 0 ] )
Returns: Number
Constraints: Rate, AnnualYield, and Redemption should be greater than 0. The Maturity date
should be greater than the Settlement date, and the Settlement should be greater than the last
interest date.
Semantics: The parameters are
Settlement: the settlement/purchase date of the security
Maturity: the maturity/expire date of the security
Last: the last interest date of the security
Rate: the interest rate of the security
AnnualYield: the annual yield of the security
Redemption: the redemption value per 100 currency units face value
Frequency: the number of interest payments per year. 1=annual; 2=half-yearly; 4=quarterly
Basis: the type which indicates how the year is to be calculated by days; see section 4.11.6
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 180 of 442
anchor:ODDLPRICE
Test Cases:
Note: OpenOffice.org 2.0 and Excel returns different results to mot of the cases. The following use
the result of Excel.
Expression Result Comment
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;5%;100
;2)
90.991042345 Without Basis parameter
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;5%;100
;1;0)
90.991042345
With Frequency=1 and
Basis=0
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;5%;100
;2;0)
90.991042345
With Frequency=2 and
Basis=0
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;5%;100
;4;0)
90.991042345
With Frequency=4 and
Basis=0
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;1.5%;1
00;1;1)
102.512087534
With Frequency=1 and
Basis=1
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;1.5%;1
00;2;1)
102.510143853
With Frequency=2 and
Basis=1
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;1.5%;1
00;4;1)
102.509884509
With Frequency=4 and
Basis=1
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;1.5%;1
00;1;2)
102.512087534
With Frequency=1 and
Basis=2
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;1.5%;1
00;2;2)
102.510143853
With Frequency=2 and
Basis=2
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;1.5%;1
00;4;2)
102.509884509
With Frequency=4 and
Basis=2
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;5%;100
0;1;3)
794.575995564
With Frequency=1 and
Basis=3
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;5%;100
0;2;3)
794.671729071
With Frequency=2 and
Basis=3
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;5%;100
794.684531308 With Frequency=4 and
Basis=3
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 181 of 442
0;4;3)
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;1.5%;1
000;1;4)
932.992137337
With Frequency=1 and
Basis=4
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;1.5%;1
000;2;4)
932.992137337
With Frequency=2 and
Basis=4
=ODDLPRICE(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;1.5%;1
000;4;4)
932.992137337
With Frequency=4 and
Basis=4
See also ODDFPRICE
6.12.35 ODDLYIELD
Summary: Compute the yield of a security which has an irregular last interest date.
Syntax: ODDLYIELD( DateParam Settlement ; DateParam Maturity ; DateParam Last ; Number
Rate ; Number Price ; Number Redemption ; Number Frequency [ ; Basis Basis = 0 ] )
Returns: Number
Constraints: Rate, Price, and Redemption should be greater than 0.
Semantics: The parameters are
Settlement: the settlement/purchase date of the security
Maturity: the maturity/expire date of the security
Last: the last interest date of the security
Rate: the interest rate of the security
Price: the price of the security
Redemption: the redemption value per 100 currency units face value
Frequency: the number of interest payments per year. 1=annual; 2=half-yearly; 4=quarterly.
Basis: the type which indicates how the year is to be calculated by days; see section 4.11.6.
anchor:ODDLYIELD
Test Cases:
Note: OpenOffice.org 2.0 and Excel returns different results to mot of the cases. The following use
the result of Excel.
Expression Result Comment
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;91;100;
2)
4.997775351% Without Basis parameter
=ODDLYIELD(DATE(1990;6;1);DATE(1 4.997775351% With Frequency=1 and
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 182 of 442
995;12;31);DATE(1990;1;1);3%;91;100;
1;0)
Basis=0
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;91;100;
2;0)
4.997775351%
With Frequency=2 and
Basis=0
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;91;100;
4;0)
4.997775351%
With Frequency=4 and
Basis=0
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;103;10
0;1;1)
1.408788601%
With Frequency=1 and
Basis=1
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;103;10
0;2;1)
1.408379719%
With Frequency=2 and
Basis=1
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;103;10
0;4;1)
1.408325114%
With Frequency=4 and
Basis=1
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;103;10
0;1;2)
1.408788601%
With Frequency=1 and
Basis=2
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;103;10
0;2;2)
1.408379719%
With Frequency=2 and
Basis=2
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;103;10
0;4;2)
1.408325114%
With Frequency=4 and
Basis=2
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;795;10
00;1;3)
4.987800402%
With Frequency=1 and
Basis=3
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;795;10
00;2;3)
4.990550494%
With Frequency=2 and
Basis=3
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);3%;795;10
00;4;3)
4.990918451%
With Frequency=4 and
Basis=3
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;933;10
00;1;4)
1.499836493%
With Frequency=1 and
Basis=4
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;933;10
00;2;4)
1.499836493%
With Frequency=2 and
Basis=4
=ODDLYIELD(DATE(1990;6;1);DATE(1
995;12;31);DATE(1990;1;1);2%;933;10
00;4;4)
1.499836493%
With Frequency=4 and
Basis=4
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 183 of 442
See also ODDLPRICE , ODDFYIELD
6.12.36 PDURATION
Summary: Returns the number of periods required by an investment to realize a specified value.
Syntax: PDURATION( Number rate ; Number currentValue ; Number specifiedValue )
Returns: Number
Constraints: rate > 0; currentValue > 0; specifiedValue > 0
Semantics: Calculates the number of periods for attaining a certain value specifiedValue, starting
from currentValue and using the interest rate rate.
rate The interest rate per period.
currentValue The current value of the investment.
specifiedValue The value, that should be reached.
PDURATION=
log( specifiedValue)log(currentValue)
log(rate)
anchor:PDURATION
Test Cases:
Expression Result Comment
=PDURATION( 0.1; 10; 100 ) 24.158858 simple use case
=PDURATION( 0.1; 100; 10 ) -24.158858 curentValue > specifiedValue
=PDURATION( 0; 10; 11 ) Error rate > 0
=PDURATION( 0.1; 0; 11 ) Error currentValue > 0
=PDURATION( 0.1; 10; 0 ) Error specifiedValue > 0
See also DURATION
Note: In OOo2, this function is named DURATION and DURATION with 6 parameters is named
DURATION_ADD. In Gnumeric, this function is name G_DURATION. Excel and Kspread don't have
it.
6.12.37 PMT
Summary: Compute the payment made each period for an investment.
Syntax: PMT( Number Rate ; Integer Nper ; Number Pv [ ; [ Number Fv = 0 ] [ ; Number PayType =
0 ] ] )
Returns: Currency
Constraints: Nper > 0
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 184 of 442
Semantics: Computes the payment made each period for an investment. The parameters are:
Rate: the interest rate per period.
Nper: the total number of payment periods.
Pv: the present value of the investment.
Fv: the future value of the investment; default is 0.
PayType: the type of payment, defaults to 0. It is 0 if payments are due at the end of the period;
1 if they are due at the beginning of the period. With PayType=1 the first payment is made on
the same day the loan is taken out.
If Rate is 0, the following equation is solved:
Pv =Fv( PMTNper )
If Rate is nonzero, then PMT solves this equation:
0 = Pv(1+Rate)
Nper
+
PMT(1+RatePayType)((1+Rate)
Nper
1)
Rate
+Fv
anchor:PMT
Test Cases:
Expression Result Comment
=PMT(5%;12;1000)
-
112.82541
0.001
A trivial example of PMT.
=PMT(5%;12;1000;100)
-
119.10795
0.001
A trivial example of PMT with non-zero FV.
=PMT(5%;12;1000;100;1)
-
113.43614
0.001
A trivial example of PMT with non-zero FV
and PayType.
=PMT(0;10;1000) -100 Rate can be zero.
See also FV, NPER, PV, RATE
6.12.38 PPMT
Summary: Calculate the payment for a given period on the principal for an investment at a given
interest rate and constant payments.
Syntax: PPMT( Number Rate ; Integer Period ; Integer nPer ; Number Present [ ; Number Future =
0 [ ; Number Type = 0 ] ] )
Returns: Number
Constraints: Rate and Present should be greater than 0. 0<Period <nPer.
Semantics: The parameters are
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 185 of 442
Rate: the interest rate
Period: the given period that the payment returned is for
nPer: the total number of periods
Present: the present value
Future: optional, the future value specified after nPer periods. The default value is 0.
Type: optional, 0 or 1, respectively for payment at the end or at the beginning of a period. The
default value is 0.
anchor:PPMT
Test Cases:
Expression Result Comment
=PPMT(3%;1;12;100) -7.046208547 A simple test case
=PPMT(3%;1;12;100;1;200) -21.138625642 With future value
=PPMT(3%;1;12;100;1;200;1) -23.435558876 With future value and type
=PPMT(8%;5;24;10000;0) -203.773514049 With nPer=5 and Future=0
=PPMT(8%;10;24;10000;2000) -359.292174601 With nPer=10 and Future=2000
=PPMT(8%;10;24;10000;2000;1) -332.677939445 With Type=1
See also PMT
6.12.39 PRICE
Summary: Calculates a quoted price for an interest paying security, per 100 currency units of face
value.
Syntax: PRICE( DateParam Settlement ; DateParam Maturity ; Number Rate ; Number AnnualYield
; Number Redemption ; Number Frequency [ ; Basis Basis = 0 ] )
Returns: Number
Constraints: Rate, AnnualYield, and Redemption should be greater than 0; Frequency = 1, 2 or 4.
Semantics: If A is the number of days from the Settlement date to next coupon date, B is the
number of days of the coupon period that the Settlement is in, C is the number of coupons between
Settlement date and Redemption date, D is the number of days from beginning of coupon period to
Settlement date, then PRICE is calculated as
PRICE=
Redemption
(1+
Yield
Frenquency
)
C1+
A
B
+
k=1
C
100Rate
Frequency
(1+
Yield
Frequency
)
k 1+
A
B
100
Rate
Frequency
D
B
The parameters are
Settlement: the settlement/purchase date of the security
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 186 of 442
Maturity: the maturity/expire date of the security
Rate: the interest rate of the security
AnnualYield: a measure of the annual yield of a security (compounded at each interest
payment)
Redemption: the redemption value per 100 currency units face value
Frequency: the number of interest payments per year. 1=annual; 2=half-yearly; 4=quarterly.
Basis: the date system to be used; see section 4.11.6.
anchor:PRICE
Test Cases:
Note: OpenOffice.org 2.0 and Gnumeric 1.4.3 return different results than Excel to some test cases.
The following use the result of Excel.
Expression Result Comment
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);3%;5%;100;2)
90.362242031 Without Basis parameter
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);3%;5%;100;1;0)
90.447956788
With Frequency=1 and
Basis=0
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);3%;5%;100;2;0)
90.362242031
With Frequency=2 and
Basis=0
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);3%;5%;100;4;0)
90.312119456
With Frequency=4 and
Basis=0
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);2%;1.5%;100;1;1)
102.655378584
With Frequency=1 and
Basis=1
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);2%;1.5%;100;2;1)
102.666400550
With Frequency=2 and
Basis=1
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);2%;1.5%;100;4;1)
102.671274947
With Frequency=4 and
Basis=1
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);2%;1.5%;100;1;2)
102.652722996
With Frequency=1 and
Basis=2
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);2%;1.5%;100;2;2)
102.665343423
With Frequency=2 and
Basis=2
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);2%;1.5%;100;4;2)
102.670408746
With Frequency=4 and
Basis=2
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);3%;5%;1000;1;3)
775.822460005
With Frequency=1 and
Basis=3
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);3%;5%;1000;1;3)
773.463160331
With Frequency=2 and
Basis=3
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);3%;5%;1000;1;3)
772.372534175
With Frequency=4 and
Basis=3
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 187 of 442
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);2%;1.5%;1000;1;4)
930.898194736
With Frequency=1 and
Basis=4
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);2%;1.5%;1000;2;4)
930.654696610
With Frequency=2 and
Basis=4
=PRICE(DATE(1990;6;1);DATE(1995;1
2;31);2%;1.5%;1000;4;4)
930.530797527
With Frequency=4 and
Basis=4
See also PRICEDISC, PRICEMAT
6.12.40 PRICEDISC
Summary: Calculate the price of a security with a discount per 100 currency units of face value.
Syntax: PRICEDISC( DateParam Settlement ; DateParam Maturity ; Number Discount ; Number
Redemption [ ; Basis Basis = 0 ] )
Returns: Number
Constraints: Discount and Redemption should be greater than 0.
Semantics: The parameters are
Settlement: the settlement/purchase date of the security
Maturity: the maturity/expire date of the security
Discount: the discount rate of the security
Redemption: the redemption value per 100 currency units face value
Basis: the type which indicates how the year is to be calculated by days; see section 4.11.6.
anchor:PRICEDISC
Test Cases:
Note: OpenOffice.org 2.0 and Excel returns different results to some test cases. The following use
the result of Excel.
Expression Result Comment
=PRICEDISC(DATE(1990;6;1);DATE(1
990;12;31);10%;1000)
941.666666667 Without Basis parameter
=PRICEDISC(DATE(1990;6;1);DATE(1
990;12;31);10%;1000;1)
941.643835616 With Basis=1
=PRICEDISC(DATE(1990;6;1);DATE(1
990;12;31);10%;1000;2)
940.833333333 With Basis=2
=PRICEDISC(DATE(1990;6;1);DATE(1
990;12;31);10%;1000;3)
941.643835616 With Basis=3
=PRICEDISC(DATE(1990;6;1);DATE(1
990;12;31);10%;1000;4)
941.944444444 With Basis=4
=PRICEDISC(DATE(1990;1;1);DATE(1 97.082191781 With discount=5%
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 188 of 442
990;12;31);5%;100;1)
=PRICEDISC(DATE(1990;6;1);DATE(1
990;6;30);3%;100;4)
99.758333333 With discount=3%
See also PRICE, PRICEMAT, YIELDDISC
6.12.41 PRICEMAT
Summary: Calculate the price per 100 currency units of face value of the security that pays interest
on the maturity date.
Syntax: PRICEMAT( DateParam Settlement ; DateParam Maturity ; DateParam Issue ; Number
Rate ; Number AnnualYield [ ; Basis Basis = 0 ] )
Returns: Number
Constraints: Settlement < Maturity, Rate >= 0, AnnualYield >= 0
Semantics: The parameters are
Settlement: the settlement/purchase date of the security
Maturity: the maturity/expire date of the security
Issue: the issue date of the security
Rate: the interest rate of the security
AnnualYield: the annual yield of the security
Basis: the type which indicates how the year is to be calculated by days; see section 4.11.6.
If both, Rate and AnnualYield, are 0, the return value is 100.
anchor:PRICEMAT
Test Cases:
Note: OpenOffice.org 2.0 and Excel returns different results to some test cases. The following use
the result of Excel.
Expression Result Comment
=PRICEMAT(DATE(1990;6;1);DATE(19
95;12;31);DATE(1990;1;1);6%;5%)
103.819218241 Without Basis parameter
=PRICEMAT(DATE(1990;6;1);DATE(19
95;12;31);DATE(1990;1;1);6%;5%;1)
103.824693325 With Basis=1
=PRICEMAT(DATE(1990;6;1);DATE(19
95;12;31);DATE(1990;1;1);6%;5%;2)
103.858482159 With Basis=2
=PRICEMAT(DATE(1990;6;1);DATE(19
95;12;31);DATE(1990;1;1);6%;5%;3)
103.824693325 With Basis=3
=PRICEMAT(DATE(1990;6;1);DATE(19
95;12;31);DATE(1990;1;1);6%;5%;4)
103.817732653 With Basis=4
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 189 of 442
=PRICEMAT(DATE(1990;6;1);DATE(19
92;12;31);DATE(1990;1;1);3%;2%;0)
102.395007924
=PRICEMAT(DATE(1990;6;1);DATE(19
91;12;31);DATE(1990;1;1);5%;3%;2)
102.967175933
See also PRICEDISC, PRICEMAT
6.12.42 PV
Summary: Compute the present value (PV) of an investment.
Syntax: PV( Number Rate ; Number Nper ; Number Payment [ ; [ Number Fv = 0 ] [ ; Number
PayType = 0 ] ] )
Returns: Currency
Constraints: None.
Semantics: Computes the present value of an investment. The parameters are:
Rate: the interest rate per period.
Nper: the total number of payment periods.
Payment: the payment made in each period.
Fv: the future value; default is 0.
PayType: the type of payment, defaults to 0. It is 0 if payments are due at the end of the period;
1 if they are due at the beginning of the period.
If Rate is 0, then:
PV =Fv( PaymentNper )
If Rate is nonzero, then PV solves this equation:
0 = PV(1+Rate)
Nper
+
Payment(1+RatePayType)((1+Rate)
Nper
1)
Rate
+Fv
anchor:PV
Test Cases:
Expression Result Comment
=PV(10%;12;-100;100) 649.510.01 A trivial example of PV.
See also FV, NPER, PMT, RATE
6.12.43 RATE
Summary: Compute the interest rate per period of an investment.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 190 of 442
Syntax: RATE( Number Nper ; Number Payment ; Number Pv [ ; [ Number Fv = 0 ] [ ; [ Number
PayType = 0 ] [ ; Number Guess = 0.1 ] ] ] )
Returns: Percentage
Constraints: If Nper is 0 or less than 0, the result is an Error.
Semantics: Computes the interest rate of an investment. The parameters are:
Nper: the total number of payment periods.
Payment: the payment made in each period.
Pv: the present value of the investment.
Fv: the future value; default is 0.
PayType: the type of payment, defaults to 0. It is 0 if payments are due at the end of the period;
1 if they are due at the beginning of the period.
Guess: An estimate of the interest rate to start the iterative computation. If omitted, 0.1 (10%) is
assumed.
RATE solves this equation:
0 = Fv+Pv( 1+Rate)
Nper
+
Payment( 1+RatePayType)( ( 1+Rate)
Nper
1)
Rate
anchor:rate
Test Cases:
Expression Result Comment
=RATE(12;-100;1000)
0.0292285
0.001
A trivial example of RATE.
=RATE(12;-100;1000;100)
0.01623133
0.001
A trivial example of RATE with non-zero
FV.
=RATE(12;-100;1000;100;1)
0.01996455
0.001
A trivial example of RATE with non-zero FV
and PayType.
=RATE(12;-100;1000;100;1;1%)
0.01996455
0.001
A trivial example of RATE with a guess.
=RATE(0;-100;1000) Error Nper must be greater than 0.
=RATE(48;-50;2000;0;1;0)
0.00805298
19239056
0.0000000
0001
Extreme test case with high precision, best
solution manually obtained would be
0.0080529819239063
=RATE(48;-50;2000;50;0;0) 0.00805298
19239056
0.0000000
0001
The result should be identical to the
previous one.
Payment in advance (Type<>0) can be
changed to normal payment with the
settings:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 191 of 442
Fv_normal = Fv_advanced
Payment_advanced*Type
Pv_normal = Pv_advanced +
Payment_advanced*Type
Therefore both examples should give the
same result.
TBD: In Gnumeric, Nper seems to be truncated if it is not an integer. In OOo2, Nper seems not to
be truncated if it is not an integer and the fractional part is included in the calculation. What does
excel do? We should include a test for this, but what is the right thing to do? For example, in
Gnumeric, RATE(12.9,-100,1000) is 2.92% but in OOo2 RATE(12.9,-100,1000) is 3.88%.
TODO: ECMA/MOOXML documents that the PayType could be either 0 or 1. However, that's not
what is implemented in Excel, it calculates different resutls for different fractional values of PayType.
It looks like PayType would be an offset to the end date of the payment period towards the start
date of the period.
See also FV, NPER, PMT, PV
6.12.44 RECEIVED
Summary: Calculates the amount received at maturity for a zero coupon bond.
Syntax: RECEIVED( DateParam Settlement ; DateParam Maturity ; Number Investment ; Number
Discount [ ; Basis Basis = 0 ] )
Returns: Number
Constraints: Investment and Discount should be greater than 0.
Semantics:
The parameters are
Settlement: the settlement/purchase date of the security
Maturity: the maturity/expire date of the security
Investment: the amount of investment in the security
Discount: the discount rate of the security
Basis: the day count basis used in this calculation; see section 4.11.6
The return value is:
RECEIVED=
Investment
1DiscountYEARFRAC( Settlement ; Maturity ; Basis)
anchor:RECEIVED
Test Cases:
Expression Result Comment
=RECEIVED(DATE(1990;6;1);DATE(19
90;12;31);10000;5%)
10300.4292 Without Basis parameter
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 192 of 442
=RECEIVED(DATE(1990;6;1);DATE(19
90;12;31);10000;5%;1)
10300.5503 With Basis=1
=RECEIVED(DATE(1990;6;1);DATE(19
90;12;31);10000;5%;2)
10304.8519 With Basis=2
=RECEIVED(DATE(1990;6;1);DATE(19
90;12;31);10000;6%;3)
10362.8414 With Basis=3
=RECEIVED(DATE(1990;6;1);DATE(19
90;12;31);10000;6%;4)
10362.6943 With Basis=4
Note: There is a differences between applications for the Basis=4 test case: Excel gets 10360.9049,
Gnumeric, Kspread and OOo all get 10362.6943 as a result. This looks like an error of Excel.
See also YEARFRAC
6.12.45 RRI
Summary: Returns an equivalent interest rate when an investment increases in value.
Syntax: RRI( Number N ; Number Pv ; Number Fv )
Returns: Percentage
Constraints: N > 0
Semantics: Returns the interest rate given N (the number of periods), Pv (present value), and Fv
(future value), calculated as follows:
(
Fv
Pv
)
(1/ N)
1
anchor:RRI
Test Cases:
Expression Result Comment
=RRI(1;100;200) 1 A trivial example of RRI.
=RRI(12;5000;10000)
0.0594630
9436
RRI, practical example
=RRI(12;10000;5000)
-
0.05612568
7
If future value is less than present value,
resultant rate is negative
=RRI(0;100;200) Error N must be greater than 0.
Note: In OOo, N is NOT truncated to an integer. There doesn't seem to be a reason to require it, so
this is expected to stay a Number and not an Integer.
See also FV, NPER, PMT, PV, RATE
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 193 of 442
6.12.46 SLN
Summary: Compute the amount of depreciation at a given period of time using the straight-line
depreciation method.
Syntax: DDB( Number Cost ; Number Salvage ; Number LifeTime )
Returns: Currency
Constraints: None.
Semantics: Compute the amount of depreciation of an asset at a given period of time using
straight-line depreciation. The parameters are:
Cost: the total amount paid for the asset.
Salvage: the salvage value at the end of the LifeTime (often 0)
LifeTime: the number of periods that the depreciation will occur over. A positive integer.
For alternative methods to compute depreciation, see DDB.
anchor:SLN
Test Cases:
Expression Result Comment
=SLN(4000;500;4) 875 A trivial example of SLN.
See also DDB
6.12.47 SYD
Summary: Compute the amount of depreciation at a given period of time using the Sum-of-the-
Years'-Digits method.
Syntax: SYD( Number Cost ; Number Salvage ; Number LifeTime ; Number Period )
Returns: Currency
Constraints: None.
Semantics: Compute the amount of depreciation of an asset at a given period of time using the
Sum-of-the-Years'-Digits method. The parameters are:
Cost: the total amount paid for the asset.
Salvage: the salvage value at the end of the LifeTime (often 0)
LifeTime: the number of periods that the depreciation will occur over. A positive integer.
Period: the period for which the depreciation value is specified.
SYD=
(Cost Salvage)( LifeTime+1Period)2
( LifeTime+1)LifeTime
For other methods of computing depreciation, see DDB.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 194 of 442
anchor:SYD
Test Cases:
Expression Result Comment
=SYD(4000;500;4;2
)
1050
A trivial example of SYD. Note that DDB would have calculated
1000 instead.
See also SLN, DDB
6.12.48 TBILLEQ
Summary: Compute the bond-equivalent yield for a treasury bill.
Syntax: TBILLEQ( DateParam Settlement ; DateParam Maturity ; Number Discount )
Returns: Number
Constraints: The maturity date should be less than one year beyond settlement date. Discount is
any positive value.
Semantics: The parameters are defined as,
Settlement: the settlement/purchase date of the treasury bill
Maturity: the maturity/expire date of the treasury bill
Discount: the discount rate of the treasury bill.
TBILLEQ is calculated as
TBILLEQ=
365rate
360(rateDSM)
where DSM is the number of days between settlement and maturity computed according to the 360
days per year basis (basis 2, 4.11.6)
anchor:TBILLEQ
Test Cases:
Note: Lotus 1-2-3 and Excel returns different results to some test cases. The following use the
result of Lotus 1-2-3, because I verified with one case by Excel formula and found that the result of
Lotus 1-2-3 is correct. To be verified with others later.
Expression Result Comment
=TBILLEQ(DATE(1996;1;1);DATE(1996;2;1);5%) 0.050913656
=TBILLEQ(DATE(1995;12;31);DATE(1996;2;1);5%) 0.050920759
=TBILLEQ(DATE(1995;12;31);DATE(1996;7;1);5%) 0.052016531
=TBILLEQ(DATE(1995;12;31);DATE(1996;12;31);5%) 0.053409423
=TBILLEQ(DATE(1996;1;1);DATE(1996;6;30);5%) 0.052001710
=TBILLEQ(DATE(1996;1;1);DATE(1996;7;1);5%) 0.052009119
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 195 of 442
=TBILLEQ(DATE(1996;1;1);DATE(1996;12;31);5%) 0.053401609
=TBILLEQ(DATE(1996;1;1);DATE(1997;1;1);5%) 0.053409423
=TBILLEQ(DATE(1996;7;1);DATE(1997;7;1);5%) 0.053401609
See also TBILLPRICE, TBILLYIELD
6.12.49 TBILLPRICE
Summary: Compute the price per 100 face value for a treasury bill.
Syntax: TBILLPRICE( DateParam Settlement ; DateParam Maturity ; Number Discount )
Returns: Number
Constraints: The maturity date should be less than one year beyond settlement. Discount is any
positive value.
Semantics: The parameters are:
Settlement: the settlement/purchase date of the treasury bill
Maturity: the maturity/expire date of the treasury bill
Discount: the discount rate of the treasury bill.
anchor:TBILLPRICE
Test Cases:
Expression Result Comment
=TBILLPRICE(DATE(1996;1;1);DATE(1996;2;1);5%) 99.56944444
=TBILLPRICE(DATE(1995;12;31);DATE(1996;2;1);5%) 99.55555556
=TBILLPRICE(DATE(1995;12;31);DATE(1996;7;1);5%) 97.45833333
=TBILLPRICE(DATE(1995;12;31);DATE(1996;12;31);5%) 94.91666667
=TBILLPRICE(DATE(1996;1;1);DATE(1996;6;30);5%) 97.48611111
=TBILLPRICE(DATE(1996;1;1);DATE(1996;7;1);5%) 97.47222222
=TBILLPRICE(DATE(1996;1;1);DATE(1996;12;31);5%) 94.93055556
=TBILLPRICE(DATE(1996;1;1);DATE(1997;1;1);5%) 94.91666667
=TBILLPRICE(DATE(1996;7;1);DATE(1997;7;1);5%) 94.93055556
See also TBILLEQ, TBILLYIELD
6.12.50 TBILLYIELD
Summary: Compute the yield for a treasury bill.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 196 of 442
Syntax: TBILLYIELD( DateParam Settlement ; DateParam Maturity ; Number Price )
Returns: Number
Constraints: The maturity date should be less than one year beyond settlement. Price is any
positive value.
Semantics: The parameters are:
Settlement: the settlement/purchase date of the treasury bill
Maturity: the maturity/expire date of the treasury bill
Price: the price of the treasury bill per 100 face value
anchor:TBILLYIELD
Test Cases:
Expression Result Comment
=TBILLYIELD(DATE(1996;1;1);DATE(1996;2;1);99.57) 0.0501511
=TBILLYIELD(DATE(1995;12;31);DATE(1996;2;1);99.56) 0.0497188
=TBILLYIELD(DATE(1995;12;31);DATE(1996;7;1);97.46) 0.0512695
=TBILLYIELD(DATE(1995;12;31);DATE(1996;12;31);94.92) 0.0526414
=TBILLYIELD(DATE(1996;1;1);DATE(1996;6;30);97.49) 0.0512080
=TBILLYIELD(DATE(1996;1;1);DATE(1996;7;1);97.47) 0.0513429
=TBILLYIELD(DATE(1996;1;1);DATE(1996;12;31);94.93) 0.0526762
=TBILLYIELD(DATE(1996;1;1);DATE(1997;1;1);94.92) 0.0526414
=TBILLYIELD(DATE(1996;7;1);DATE(1997;7;1);94.93) 0.0526762
See also TBILLEQ, TBILLPRICE
6.12.51 VDB
Summary: Calculates the depreciation allowance of an asset with an initial value, an expected
useful life, and a final value of salvage for a period specified, using the variable-rate declining
balance method..
Syntax: VDB( Number cost ; Number salvage ; Number lifeTime ; Number startPeriod ; Number
endPeriod [ ; Number depreciationFactor = 2 [ ; Logical noSwitch = FALSE() ] ] )
Returns: Number
Constraints: salvage < cost, lifeTime > 0, 0 startPeriod lifeTime, startPeriod endPeriod
lifeTime, depreciationFactor 0
Semantics: cost is the amount paid for the asset. cost can be any value greater than salvage.
salvage is the value of the asset at the end of its life. salvage can be any value.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 197 of 442
lifeTime is the number of periods the asset takes to depreciate to its salvage value. lifeTime can be
any value greater than 0.
startPeriod is the point in the asset's life when you want to begin calculating depreciation. start-
Period can be any value greater than or equal to 0, but cannot be greater than lifeTime.
endPeriod is the point in the asset's life when you want to stop calculating depreciation. end-Period
can be any value greater than startPeriod.
startPeriod and endPeriod correspond to the asset's life, relative to the fiscal period. For example, if
you want to find the first year's depreciation of an asset purchased at the beginning of the second
quarter of a fiscal year, start-period would be 0 and end-period would be 0.75 (1 minus 0.25 of a
year).
VDB allows for the use of an initialPeriod option to calculate depreciation for the period the asset is
placed in service. VDB uses the fractional part of startPeriod and endPeriod to determine the
initialPeriod option. If both startPeriod and endPeriod have fractional parts, then VDB uses the
fractional part of startPeriod.
depreciationFactor is an optional argument that specifies the percentage of straight-line depreciation
you want to use as the depreciation rate. If you omit this argument, VDB uses 2, which is the
double-declining balance rate. depreciation-factor can be any value greater than or equal to 0;
commonly used rates are 1.25, 1.50, 1.75, and 2.
noSwitch is an optional argument that you include if you do not want VDB to switch to straight-line
depreciation for the remaining useful life. Normally, declining-balance switches to such a straight-
line calculation when it is greater than the declining-balance calculation.
If noSwitch is FALSE() or omitted, VDB automatically switches to straight-line depreciation when
that is greater than declining-balance depreciation. If noSwitch is TRUE(), VDB never switches to
straight-line depreciation.
anchor:VDB
Test Cases:
This example calculates depreciation for an office machine, purchased in the middle of the first
quarter of the fiscal year, that cost $10,000. The useful life of the machine is 10 years, and the
salvage value after 10 years is $600. The following formulas calculate the depreciation expense for
each of the 10 years, using the variable-rate declining balance method, with a depreciation rate of
150%. Notice that the switch to straight-line depreciation occurs in the sixth year.
Expression Result Comment
=VDB(10000;600;10;0;0.875;1.5) 1312.5
=VDB(10000;600;10;0.875;1.875;1.5) 1303.13
=VDB(10000;600;10;1.875;2.875;1.5) 1107.66
=VDB(10000;600;10;2.875;3.875;1.5 941.5
=VDB(10000;600;10;3.875;4.875;1.5) 800.28
=VDB(10000;600;10;4.875;5.875;1.5) 767.79
=VDB(10000;600;10;5.875;6.875;1.5) 767.79
=VDB(10000;600;10;6.875;7.875;1.5) 767.79
=VDB(10000;600;10;7.875;8.875;1.5) 767.79
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 198 of 442
=VDB(10000;600;10;8.875;9.875;1.5) 767.79
=VDB(10000;600;10;9.875;10;1.5) 95.97
See also DDB, SLN
6.12.52 XIRR
Summary: Compute the internal rate of return for a non-periodic series of cash flows.
Syntax: XIRR( NumberSequence Values ; DateSequence Dates [ ; Number Guess = 0.1 ] )
Returns: Number
Constraints: The size of Values and Dates are equal. Values contains at least one positive and one
negative cash flow.
Semantics: Compute the internal rate of return for a series of cash flows which is not necessarily
periodic. The parameters are
Values: a series of cash flows. The first cash-flow amount is a negative number that represents
the investment. The later cash flows are discounted based on the annual discount rate and the
timing of the flow. The series of cash flow should contain at least one positive and one negative
value.
Dates: a series of dates that corresponds to values. The first date indicates the start of the cash
flows. The range of Values and Dates shall be the same size.
Guess: If provided, Guess is an estimate of the interest rate to start the iterative computation. If
omitted, the value 0.1 (10%) is assumed. The result of XIRR is the rate at which the XNPV()
function will return zero with the given cash flows. There is no closed form for XIRR.
Implementations may return an approximate solution using an iterative method, in which case
the Guess parameter may be used to initialize the iteration. If the implementation is unable to
converge on a solution given a particular Guess, it may return an error.
anchor:XIRR
Test Cases:
Expression Result Comment
=XIRR(B1:B4;C1:C4) 0.2115964
Suppose B1:B4 contains -20000, 4000, 12000, 8000
while C1:C4 contains =DATE(2000;1;1),
=DATE(2000;6;1), =DATE(2000;12;30),
=DATE(2001;3;1)
=XIRR(B1:B2;C1:C2;
20%)
0.2492381
Suppose B1:B2 contains -20000, 25000 while C1:C2
contains =DATE(2000;1;1), =DATE(2001;1;1).
=XIRR(B1:B3;C1:C3) 0.1405418
Suppose B1:B3 contains -10000, 4000, 12000;
C1:C3 contains =DATE(2000;1;1),
=DATE(2002;6;1), =DATE(2004;1;1)
TODO: Fix test cases above so that data is actually in test case data.
See also IRR
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 199 of 442
6.12.53 XNPV
Summary: Compute the net present value of a series of cash flows.
Syntax: XNPV( Number Rate ; Reference|Array Values ; Reference| Array Dates )
Returns: Number
Constraints:
Number of elements in Values equals number of elements in Dates.
All elements of Values are of type Number.
All elements of Dates are of type Number.
All elements of Dates >= Dates[1]
Semantics: Compute the net present value for a series of cash flows which is not necessarily
periodic. The parameters are
Rate: discount rate. The value should be greater than -1.
Values: a series of cash flows. The first cash-flow amount is a negative number that represents
the investment. The later cash flows are discounted based on the annual discount rate and the
timing of the flow. The series of cash flow should contain at least one positive and one negative
value.
Dates: a series of dates that corresponds to values. The first date indicates the start of the cash
flows. If the dimensions of the Values and Dates arrays differ, evaluators shall match value and
date pairs row-wise starting from top left.
With N being the number of elements in Values and Dates each, the formula is:
XNPV=
i=1
N
Values
i
( 1+Rate)
Dates
i
Dates
1
365
anchor:XNPV
Test Cases:
Expression Result Comment
=XNPV(5%;B1:B4;C1:C
4)
2907.83187
Suppose B1:B4 contains -20000, 4000, 12000,
8000 while C1:C4 contains =DATE(2000;1;1),
=DATE(2000;6;1), =DATE(2000;12;30),
=DATE(2001;3;1)
=XNPV(6%;B1:B2;C1:C
2)
3581.14085
Suppose B1:B2 contains -20000, 25000 while
C1:C2 contains =DATE(2000;1;1),
=DATE(2001;1;1).
=XNPV(5%;B1:B3;C1:C
3)
3426.25543
Suppose B1:B3 contains -10000, 4000, 12000;
C1:C3 contains =DATE(2000;1;1),
=DATE(2002;6;1), =DATE(2004;1;1)
TODO: Fix test cases above so that data is actually in test case data.
See also NPV
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 200 of 442
6.12.54 YIELD
Summary: Calculate the yield of a bond.
Syntax: YIELD( DateParam Settlement ; DateParam Maturity ; Number Rate ; Number Price ;
Number Redemption ; Number Frequency [ ; Basis Basis = 0 ] )
Returns: Number
Constraints: Rate, Price, and Redemption should be greater than 0.
Semantics: The parameters are
Settlement: the settlement/purchase date of the bond
Maturity: the maturity/expire date of the bond
Rate: the interest rate of the bond
Price: the price of the bond per 100 currency units face value
Redemption: the redemption value of the bond per 100 currency units face value
Frequency: the number of interest payments per year. 1=annual; 2=half-yearly; 4=quarterly
Basis: the day count convention to use, see section 4.11.6
anchor:YIELD
Test Cases:
Note: OpenOffice.org 2.0 and Excel returns different results to some test cases. The following use
the result of Excel.
Expression Result Comment
=YIELD(DATE(1990;6;1);DATE(1995;1
2;31);3%;90.36224;100;2)
0.050000004 Without Basis parameter
=YIELD(DATE(1990;6;1);DATE(1995;1
2;31);3%;90.44796;100;1;0)
0.049999993
With Frequency=1 and
Basis=0
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);3%
;90.36224;100;2;0)
0.050000004
With Frequency=2 and
Basis=0
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);3%
;90.31212;100;4;0)
0.049999999
With Frequency=4 and
Basis=0
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);2%
;102.65538;100;1;1)
0.014999997
With Frequency=1 and
Basis=1
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);2%
;102.6664;100;2;1)
0.015000001
With Frequency=2 and
Basis=1
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);2%
;102.671275;100;4;1)
0.015036907
With Frequency=4 and
Basis=1
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 201 of 442
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);2%
;102.652723;100;1;2)
0.015000000
With Frequency=1 and
Basis=2
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);2%
;102.66534;100;2;2)
0.015000006
With Frequency=2 and
Basis=2
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);2%
;102.67041;100;4;2)
0.014999998
With Frequency=4 and
Basis=2
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);3%
;775.82246;1000;1;3)
0.050000000
With Frequency=1 and
Basis=3
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);3%
;773.46316;1000;1;3)
0.050000000
With Frequency=2 and
Basis=3
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);3%
;772.37253;1000;1;3)
0.050000001
With Frequency=4 and
Basis=3
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);2%
;930.89819;1000;1;4)
0.015000001
With Frequency=1 and
Basis=4
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);2%
;930.6547;1000;2;4)
0.014999999
With Frequency=2 and
Basis=4
=YIELD
(DATE(1990;6;1);DATE(1995;12;31);2%
;930.5308;1000;4;4)
0.015000000
With Frequency=4 and
Basis=4
See also PRICE, YIELDDISC, YIELDMAT
6.12.55 YIELDDISC
Summary: Calculate the yield of a discounted security per 100 currency units of face value.
Syntax: YIELDDISC( DateParam Settlement ; DateParam Maturity ; Number Price ; Number
Redemption [ ; Basis Basis = 0 ] )
Returns: Number
Constraints: Price and Redemption should be greater than 0.
Semantics: The parameters are
Settlement: the settlement/purchase date of the security
Maturity: the maturity/expire date of the security
Price: the price of the security per 100 currency units face value
Redemption: the redemption value per 100 currency units face value
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 202 of 442
Basis: the day count basis for this calculation; see section 4.11.6
The return value is
YIELDDISC=
Redemption
Price
1
YEARFRAC( Settlement ; Maturity ; Basis)
anchor:YIELDDISC
Test Cases:
Note: OpenOffice.org 2.0 and Excel returns different results to some test cases. The following use
the result of Excel.
Expression Result Comment
=YIELDDISC(DATE(1990;6;1);DATE(19
90;12;31);941.66667;1000)
0.106194684 Without Basis parameter
=YIELDDISC(DATE(1990;6;1);DATE(19
90;12;31);941.64384;1000;1)
0.106238821 With Basis=1
=YIELDDISC(DATE(1990;6;1);DATE(19
90;12;31);940.83333;1000;2)
0.107807168 With Basis=2
=YIELDDISC(DATE(1990;6;1);DATE(19
90;12;31); 941.64384 ;1000;3 )
0.106238821 With Basis=3
=YIELDDISC(DATE(1990;6;1);DATE(19
90;12;31);941.94444;1000;4)
0.105657842 With Basis=4
=YIELDDISC(DATE(1990;1;1);DATE(19
90;12;31);97.08219;100;1)
0.051522942
=YIELDDISC(DATE(1990;6;1);DATE(19
90;6;30);99.75833;100;4)
0.030073091
See also PRICEDISC, YEARFRAC
6.12.56 YIELDMAT
Summary: Calculate the yield of the security that pays interest on the maturity date.
Syntax: YIELDMAT( DateParam Settlement ; DateParam Maturity ; DateParam Issue ; Number
Rate ; Number Price [ ; Basis Basis = 0 ] )
Returns: Number
Constraints: Rate and Price should be greater than 0.
Semantics: The parameters are
Settlement: the settlement/purchase date of the security
Maturity: the maturity/expire date of the security
Issue: the issue date of the security
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 203 of 442
Rate: the interest rate of the security
Price: the price of the security per 100 currency units face value
Basis: the type which indicates how the year is to be calculated by days; see section 4.11.6
anchor:YIELDMAT
Test Cases:
Note: OpenOffice.org 2.0 and Excel returns different results to some test cases. The following use
the result of Excel.
Expression Result Comment
=YIELDMAT(DATE(1990;6;1);DATE(19
95;12;31);DATE(1990; 1; 1);
6%;103.819218241)
0.050000000 Without Basis parameter
=YIELDMAT(DATE(1990;6;1);DATE(19
95;12;31); DATE(1990; 1; 1);
6%;103.824693325;1)
0.050000000 With Basis=1
=YIELDMAT
(DATE(1990;6;1);DATE(1995;12;31);DA
TE(1990; 1; 1); 6%;103.858482159; 2)
0.050000000 With Basis=2
=YIELDMAT(DATE(1990;6;1);DATE(19
95;12;31);DATE(1990; 1; 1);
6%;103.824693325;3)
0.050000000 With Basis=3
=YIELDMAT
(DATE(1990;6;1);DATE(1992;12;31);DA
TE(1990;1;1); 6%,103.817732653,4)
0.050000000 With Basis=4
=YIELDMAT
(DATE(1990;6;1);DATE(1992;12;31);DA
TE(1990;1;1); 3%;102.395007924;0)
0.020000000 With Basis=0
=YIELDMAT
(DATE(1990;6;1);DATE(1995;12;31);DA
TE(1990;1;1); 5%;102.967175933;2))
0.030000000 With Basis=2
See also PRICE, YIELD, YIELDDISC
6.13 Information Functions
6.13.1 General
Information functions provide information about a data value, the spreadsheet, or underlying
environment, including special functions for converting between data types.
6.13.2 AREAS
Summary: Returns the number of areas in a given reference
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 204 of 442
Syntax: AREAS( ReferenceList R )
Returns: Number
Constraints: None
Semantics: Returns the number of areas in the reference list.
anchor:AREAS
Test Cases:
Expression Result Comment
=AREAS([.B3]) 1 A reference to a single cell has one area
=AREAS([.B3:.C4]) 1 A reference to a single range has one area
=AREAS([.B3:.C4]~[.D5:.D
6)
2 Cell concatenation creates multiple areas
=AREAS([.B3:.C4]~[.B3]) 2
Cell concatenation counts, even if the cells
are duplicated
See also Infix Operator Reference Concatenation, INDEX
6.13.3 CELL
Summary: Returns information about position, formatting or contents in a reference.
Syntax: CELL( Text Info_Type [ ; Reference R ] )
Returns: Information about position, formatting properties or content
Constraints: None
Semantics: The parameters are
Info_Type: the text string which specifies the type of information. Please refer to the following
table.
Table 19 - CELL
Info_Type Comment
COL Returns the column number of the cell.
ROW Returns the row number of the cell.
SHEET Returns the sheet number of the cell.
ADDRESS
Returns the absolute address of the cell. The sheet name is included if
given in the reference. For an external reference a Source as specified
in the syntax rules for References is included.
FILENAME
Returns the file name of the file that contains the cell as an IRI. If the file
is newly created and has not yet been saved, the file name is empty
text .
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 205 of 442
CONTENTS Returns the contents of the cell, without formatting properties.
COLOR
Returns 1 if color formatting is set for negative value in this cell;
otherwise returns 0
FORMAT
Returns a text string which shows the number format of the cell.
,(comma) = number with thousands separator
F = number without thousands separator
C = currency format
S = exponential representation
P = percentage
To indicate the number of decimal places after the decimal separator, a
number is given right after the above characters.
D1 = MMM-D-YY, MM-D-YY and similar formats
D2 = DD-MM
D3 = MM-YY
D4 = DD-MM-YYYY HH:MM:SS
D5 = MM-DD
D6 = HH:MM:SS AM/PM
D7 = HH:MM AM/PM
D8 = HH:MM:SS
D9 = HH:MM
G = All other formats
- (Minus) at the end = negative numbers in the cell have color setting
() (brackets) at the end = this cell has the format settings with
parentheses for positive or all values
TYPE
Returns the text value corresponding to the type of content in the cell:
b : blank or empty cell content
l : label or text cell content
v : number value cell content
WIDTH
Returns the column width of the cell.
The unit is the width of one zero (0) character in default font size.
PROTECT
Returns the protection status of the cell:
1 = cell is protected
0 = cell is unprotected
PARENTHESES Returns 1 if the cell has the format settings with parentheses for positive
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 206 of 442
or all values, otherwise returns 0
PREFIX
Returns single character text strings corresponding to the alignment of
the cell.
' (APOSTROPHE, U+0027) = left alignment
'"' (QUOTATION MARK, U+0022) = right alignment
^(caret) = centered alignment
\(back slash) = filled alignment
otherwise, returns empty string "".
R : if R is a reference to a cell, it is the cell whose information will be returned; if R is a reference
to a range, the top-left cell in the range is the selected one; if R is omitted, the current cell is
used.
anchor:CELL
Test Cases:
Expression Result Comment
=CELL("COL";[.B7]) 2 Column B is column number 2.
=CELL("ADDRESS";[.B7]) "$B$7" Absolute address
=CELL("ADDRESS";
[Sheet2.B7])
"$Sheet2.$B$7"
Absolute address including sheet
name
=CELL("ADDRESS";
['x:\sample.ods'#Sheet3.B
7])
"'file:///x:/sample.ods'#
$Sheet3.$B$7"
Absolute address including sheet
name and IRI of location of
document
=CELL("FILENAME") "file:///x:/sample.ods"
The current cell is saved in a file
named sample.ods which is
located at file:///x:/
=CELL("FORMAT";[.C7]) "D4"
C7's number format is like DD-
MM-YYYY HH:MM:SS
Rationale: COORD is one Info_Type in OpenOffice.org; it was removed because involving a
specific product's address format into the standard did not seem appropriate.
6.13.4 COLUMN
Summary: Returns the column number(s) of a reference
Syntax: COLUMN( [ Reference R ] )
Returns: Number
Constraints: AREAS(R) = 1
Semantics: Returns the column number of a reference, where A is 1, B is 2, and so on. If no
parameter is given, the current cell is used. If a reference has multiple columns, an array of numbers
is returned with all of the columns in the reference.
anchor:COLUMN
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 207 of 442
Test Cases:
Expression Result Comment
=COLUMN([.B7]) 2 Column B is column number 2.
=COLUMN() 5
Column of current cell is default, here
formula in column E.
{=COLUMN([.B2:.D2])} {2;3;4} Array with column numbers.
See also ROW, SHEET
6.13.5 COLUMNS
Summary: Returns the number of columns in a given range
Syntax: COLUMNS( Reference|Array R )
Returns: Number
Constraints: None
Semantics: Returns the number of columns in the range or array specified. The result is not
dependent on the cell content in the range.
anchor:COLUMNS
Test Cases:
Expression Result Comment
=COLUMNS([.C1]) 1 Single cell range contains one column.
=COLUMNS([.C1:.C4]) 1 Range with only one column.
=COLUMNS([.A4:.D100]) 4 Number of columns in range.
See also ROWS
Note: Need to determine that null range and sheet traversal works in other implementations. Only
checked OO. The null range gives an Error in Gnumeric and Excel, so removed test.
Note: Excel supports inline Arrays. OpenOffice.org 2 does not support inline arrays.
6.13.6 COUNT
Summary: Count the number of Numbers provided
Syntax: COUNT( { NumberSequenceList N }
+
)
Returns: Number
Constraints: One or more parameters.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 208 of 442
Semantics: Counts the numbers in the list of NumberSequences provided. Only numbers in
references are counted; all other types are ignored. Errors are not propagated. It is implementation-
defined what happens if 0 parameters are passed, but it should be an Error or 0.
anchor:COUNT
Test Cases:
Expression Result Comment
=COUNT(1;2;3) 3 Simple count.
=COUNT([.B4:.B5]) 2 Two numbers in the range.
=COUNT([.B4:.B5];
[.B4:.B5])
4 Duplicates are not removed.
=COUNT([.B4:.B9]) 2 Errors in referenced cells or ranges are ignored.
=COUNT([.B4:.B8];
1/0)
2 Errors in direct parameters are still ignored.
=COUNT([.B3:.B5]) 2 Conversion to NumberSequence ignores strings (in B3).
See also COUNTA
Note: OpenOffice.org 2.0 propagates errors, while they are skipped in Excel and Gnumeric. For the
moment, claiming that errors should be skipped. Excel 2003 documentation says that in its version
of COUNT, 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. If an
argument is an Array or Reference, only Numbers in that array or reference are counted. Empty
cells, Logical values, Text, or Error values in the array or reference are ignored. If you need to count
Logical values, Text, or Error values, use the COUNTA function.
6.13.7 COUNTA
Summary: Count the number of non-empty values
Syntax: COUNTA( { Any A }
+
)
Returns: Number
Constraints: None.
Semantics: Counts the number of non-blank values in the list of Any sequences provided. A value
is non-blank if it contains any content of any type, including an Error. In a reference, every cell that is
not empty is included in the count. An empty string value ("") is not considered blank. Errors
contained in a range are considered a non-blank value for purposes of the count; errors do not
propagate. Constant expressions or formulas are allowed; these are evaluated and if they produce
an Error value the Error value is counted as one non-blank value (and not propagated as an Error).
It is implementation-defined what happens if 0 parameters are passed, but it should be an Error or
0. Any A may be a ReferenceList.
anchor:COUNTA
Test Cases:
Expression Result Comment
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 209 of 442
=COUNTA("1";2;TRU
E())
3 Simple count of 3 constant values.
=COUNTA([.B3:.B5]) 3 Three non-empty cells in the range.
=COUNTA([.B3:.B5];
[.B3:.B5])
6 Duplicates are not removed
=COUNTA([.B3:.B9]) 6
Where B9 is "=1/0", i.e. an error, counts the error as non-empty;
errors contained in a reference do not propagate the error into
the result.
=COUNTA("1";2;1/0) 3
An error in the list of values is just counted; errors in a constant
parameter do not propagate.
=COUNTA("1";2;SU
M([.B3:.B9]))
3
Errors in an evaluated formula do not propagate; they are just
counted.
=COUNTA("1";2;
[.B3:.B9])
8
Errors in an evaluated formula do not propagate; they are just
counted.
See also COUNT, ISBLANK
6.13.8 COUNTBLANK
Summary: Count the number of blank values
Syntax: COUNTBLANK( ReferenceList R )
Returns: Number
Constraints: None.
Semantics: Counts the number of blank cells in the Reference provided. A cell is blank if the cell is
empty for purposes of COUNTBLANK. If ISBLANK(R) is true, then it is blank. A cell with numeric
value zero ('0') is not blank. It is implementation-defined whether or not a cell returning the empty
string ("") is considered blank; because of this, there is a (potential) subtle difference between
COUNTBLANK and ISBLANK.
Evaluators shall support one Reference as a parameter and may support a ReferenceList as a
parameter.
anchor:COUNTBLANK
Test Cases:
Expression Result Comment
=COUNTBLANK([.B3:.B10]
)
1
Only B8 is blank. Zero ('0') in B10 is not considered
blank.
See also COUNT, COUNTA, COUNTIF, ISBLANK
Rationale: Excel's COUNTBLANK treats the empty string "" as blank, even if it's returned by a
formula, so a cell can have a formula yet be considered blank by this function. In contrast, OOo's
COUNTBLANK considers a cell with a formula that returns to be non-blank. Thus, a cell with the
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 210 of 442
formula =IF(TRUE();"";"False") would be considered blank by Excel's COUNTBLANK, and non-
blank by OOo's COUNTBLANK. Excel's calculation is rather bizarre, because both would consider
ISBLANK(cell) to be FALSE(). In other words, in Excel, COUNTBLANK uses a different rule than
ISBLANK, creating a potential subtle difference between COUNTBLANK and ISBLANK. This
specification specifically avoids requiring such a bizarre semantic, but since some applications may
choose to implement it, it permits these semantics.
6.13.9 COUNTIF
Summary: Count the number of cells in a range that meet a criteria.
Syntax: COUNTIF( ReferenceList R ; Criterion C )
Returns: Number
Constraints: Does not accept constant values as the reference parameter.
Semantics: Counts the number of cells in the reference range R that meet the Criterion C (4.11.7).
The values returned may vary depending upon the HOST-USE-REGULAR-EXPRESSIONS or
HOST-USE-WILDCARDS properties. 3.4
anchor:COUNTIF
See also COUNT, COUNTA, COUNTBLANK, COUNTIFS, SUMIF, Infix Operator "=", Infix Operator
"<>", Infix Operator Ordered Comparison ("<", "<=", ">", ">=")
6.13.10 COUNTIFS
Summary: Count the number of cells that meet multiple criteria in multiple ranges.
Syntax: COUNTIFS( Reference R1 ; Criterion C1 [ ; Reference R2 ; Criterion C2 ]... )
Returns: Number
Constraints: Does not accept constant values as the reference parameter.
Semantics: Counts the number of cells that meet the Criterion C1 in the reference range R1 and
the Criterion C2 in the reference range R2, and so on (4.11.7). All reference ranges shall have the
same dimension and size, else an Error is returned. A logical AND is applied between each array
result of each selection; an entry is counted only if the same position in each array is the result of a
Criterion match.
The values returned may vary depending upon the HOST-USE-REGULAR-EXPRESSIONS or
HOST-USE-WILDCARDS properties. 3.4
anchor:COUNTIFS
See also COUNT, COUNTA, COUNTBLANK, COUNTIF, SUMIF, Infix Operator "=", Infix Operator
"<>", Infix Operator Ordered Comparison ("<", "<=", ">", ">=")
6.13.11 ERROR.TYPE
Summary: Returns Number representing the specific Error type.
Syntax: ERROR.TYPE( Error E )
Returns: Number
Constraints: None.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 211 of 442
Semantics: Returns a number representing what kind of Error has occurred. Note that unlike most
functions, this function does not propagate Error values. Receiving a non-Error value returns an
Error. In particular, ERROR.TYPE(NA()) returns 7, and ERROR.TYPE applied to a non-Error returns
an Error.
anchor:ERROR.TYPE
Test Cases:
Expression Result Comment
=ERROR.TYPE(NA()) 7 By convention, the ERROR.TYPE of NA() is 7.
=ERROR.TYPE(0) Error Non-errors produce an error.
See also NA
Note: Excel 2003 has the following Error values (with ERROR.TYPE values), according to
Walkenbach 2003, page 49 and Simon's "Excel 2000 in a Nutshell" page 527:
#DIV/0! (2) - Attempt to divide by zero, including division by an empty cell.
#NAME? (5) - Unrecognized/deleted name.
#N/A (7) - NA. Lookup functions which failed and NA() return this value.
#NULL! (1) - Intersection of ranges produced zero cells.
#NUM! (6) - Failed to meet domain constraints (e.g., input was too large or too small)
#REF! (4) - Reference to invalid cell.
#VALUE! (3) - Parameter is wrong type.
Note: We have decided to not mandate a standard set of Error values. Instead, we are keeping
maximum flexibility by simply asserting that there are Error values without saying what they are
other than NA. In practice, most users just treat all Errors (other than NA) alike, so it doesnt matter
to them. However, not mandating a specific set means that applications are free to be more specific
about their errors.
Note: This function could be named "ERRORTYPE" instead of "ERROR.TYPE". Note that OOo2
uses ERRORTYPE, not ERROR.TYPE, and implementations are free to display ERROR.TYPE if
they would like to. Function names generally don't have "." in them, and the "." is also used to
separate sheetnames from cellreferences. This dual use of "." isn't a problem in the ODF exchange
syntax (because "." before a cell reference can only occur inside square brackets), but it creates a
minor parsing complication when accepting human input if (1) the human doesn't enter the square
brackets (a typical use), and (2) the number of columns greatly exceeds current common
maximums (a likely future possibility). A column named "ERROR" is obviously far beyond today's
sheets (which typically stop at "IV"), but future sheets will presumably have fewer limits, and in any
case coding around special cases is not desirable. If they must code around anything, they might
code in "ERROR.TYPE" as a special case. But in the end, there wasnt a strong reason to name it
other than ERROR.TYPE, so its been left this way.
Rationale: OpenOffice.org 2's ERRORTYPE() returns _DIFFERENT_ values, e.g.,
ERRORTYPE(NA()) returns 32767, not 7. This a reasonable reason to name this function
differently, namely, ERROR.TYPE.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 212 of 442
6.13.12 FORMULA
Summary: Returns formula at given reference as text
Syntax: FORMULA( Reference X )
Returns: String
Constraints: Reference X shall contain a formula
Semantics: Returns the formula in reference X as a string. The specific syntax of this returned
string is implementation-defined. This function is intended to aid debugging by simplifying display of
formulas in other cells. Error results of the referred formula cell are not propagated.
anchor:FORMULA
Test Cases:
Expression Result Comment
=LENGTH(FORMULA([
.B7]))>0
True B7 is a formula, so this is fine and will produce a text value
=FORMULA([.B3]) True Simple formulas that produce Text are still formulas
See also ISFORMULA
6.13.13 INFO
Summary: Returns information about the environment
Syntax: INFO( Text Category )
Returns: Any (see below)
Constraints: Category shall be valid
Semantics: Returns information about the environment in the given category.
Evaluators shall support at least the following categories:
Table 20 - INFO
Category Meaning Type
"directory" Current directory. This shall be formatted so file names
can be appended to the result (e.g., on POSIX and
Windows systems it shall end with the separator / or
\ respectively).
Text
"memavail" Amount of memory available, in bytes. On many
modern (virtual memory) systems this value is not really
available, but a system should return 0 if it is known that
there is no more memory available, and greater than 0
otherwise
Number
"memused" Amount of memory used, in bytes, by the data Number
"numfile" Number of active worksheets in files Number
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 213 of 442
"osversion" Operating system version Text
"origin" The top leftmost visible cell's absolute reference
prefixed with $A:. In locales where cells are ordered
right-to-left, the top rightmost visible cell is used instead.
Text
"recalc" Current recalculation mode. If the locale is English, this
is either "Automatic" or "Manual" (the exact text
depends on the locale)
Text
"release" The version of the implementation. Text
"system" The type of the operating system. Text
"totmem" Total memory available in bytes, including the memory
already used.
Number
Evaluators may support other categories.
anchor:INFO
Note: The values for INFO(system) vary. Excel 2003 returns pcdos. OpenOffice.org 2.0.1 returns
"WNT" for Microsoft Windows , "LINUX" for Linux, and "SOLARIS" for Solaris. This is fundamentally
dependent on the environment anyway, so there's been no effort to harmonize this.
Note: The format for origin is odd, but it's that way for compatibility.
Test Cases:
Expression Result Comment
=INFO(recalc) Automatic
=ISTEXT(INFO(syst
em))
True
The details of system vary by system, but it is
always a text value
=ISTEXT(INFO("com
pletely-unknown-
category"))
Error Error if the category is unknown
=ISTEXT(INFO("direc
tory"))
Test to see that every required category is supported
=ISNUMBER(INFO("
memavail"))
=ISNUMBER(INFO("
memused"))
=ISNUMBER(INFO("
numfile"))
=ISTEXT(INFO("osve
rsion"))
=ISTEXT(INFO("origi
n"))
=ISTEXT(INFO("recal
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 214 of 442
c"))
=ISTEXT(INFO("relea
se"))
=ISTEXT(INFO("syst
em"))
=ISNUMBER(INFO("t
otmem"))
See also CELL
6.13.14 ISBLANK
Summary: Return TRUE if the referenced cell is blank, else return FALSE
Syntax: ISBLANK( Scalar X )
Returns: Logical
Constraints: None
Semantics: If X is of type Number, Text, or Logical, return FALSE. If X is a reference to a cell,
examine the cell; if it is blank (has no value), return TRUE, but if it has a value, return FALSE. A cell
with the empty string is not considered blank.
anchor:ISBLANK
Test Cases:
Expression Result Comment
=ISBLANK(1) False Numbers return false.
=ISBLANK("") False Text, even empty string, returns false.
=ISBLANK([.B8]) True Blank cell is true.
=ISBLANK([.B7]) False Non-blank cell is false.
See also ISNUMBER, ISTEXT
6.13.15 ISERR
Summary: Return True if the parameter has type Error and is not NA, else return False.
Syntax: ISERR( Scalar X )
Returns: Logical
Constraints: None
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 215 of 442
Semantics: If X is of type Error, and ISNA(X) is not true, returns TRUE. Otherwise it returns FALSE.
Note that this function returns False if given NA(); if this is not desired, use ISERROR. Note that this
function does not propagate Error values.
ISERR(X) is the same as:
IF(ISNA(X),FALSE(),ISERROR(X))
anchor:ISERR
Test Cases:
Expression Result Comment
=ISERR(1/0) True Error values other than NA() return true.
=ISERR(NA()) False NA() does NOT return True.
=ISERR("#N/A") False Text is not an error.
=ISERR(1) False Numbers are not an error.
See also ERROR.TYPE, ISERROR, ISNUMBER, ISTEXT, NA
Note: In Lotus 1-2-3v9, the function named ISERR actually maps to ISERROR, not to ISERR. This
is because in Lotus 1-2-3v9, @ISERR(@NA) is 1 (True). In Quattro Pro, Excel, OpenOffice.org,
SheetToGo, etc., ISERR(NA()) is 0 / False. The function named ISERR is given here with the
semantics of the majority.
6.13.16 ISERROR
Summary: Return TRUE if the parameter has type Error, else return FALSE
Syntax: ISERROR( Scalar X )
Returns: Logical
Constraints: None
Semantics: If X is of type Error, returns TRUE, else returns FALSE. Note that this function returns
True if given NA(); if this is not desired, use ISERR. Note that this function does not propagate Error
values.
anchor:ISERROR
Test Cases:
Expression Result Comment
=ISERROR(1/0) True Error values return true.
=ISERROR(NA()) True Even NA().
=ISERROR("#N/A") False Text is not an error.
=ISERROR(1) False Numbers are not an error.
=ISERROR(CHOOS
E(0; "Apple";
True If CHOOSE given out-of-range
value, ISERROR needs to
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 216 of 442
"Orange"; "Grape";
"Perry"))
capture it.
See also ERROR.TYPE, ISERR, ISNA, ISNUMBER, ISTEXT, NA
Note: KSpread 1.4.2 lacks ISERROR, ISERR, and ISNA. However, KSpread developer Tomas
Mecir announced on January 9, 2006, that he had added implementations of these functions due to
an early draft of the OpenFormula specification, and a future release of KSpread will include these
functions.
OOo2's ISERROR() function lets some errors slip through, instead of being captured. E.G.,
ISERROR(CHOOSE(0;"Apple";"Orange";"Grape";"Perry")) produces an Error, rather than TRUE.
Rationale: Lotus 1-2-3 and Quattro Pro lack ISERROR. They work as though NA were not an Error
value, but something else.. but it's believed NA can still be modelled as an Error value even in those
cases, because it has the same effect. We've left them in the small group, since it's hard to do
some kinds of things (including automated testing) without them.
6.13.17 ISEVEN
Summary: Return TRUE if the value is even, else return FALSE
Syntax: ISEVEN( Number X )
Returns: Logical
Constraints: None
Semantics: First, compute X1=TRUNC(X). Then, if X1 is even (a division by 2 has a remainder of
0), return True, else return False. The result is implementation-defined if given a Logical value; an
evaluator may return either an Error or the result of converting the Logical value to a Number (per
Conversion to Number ).
anchor:ISEVEN
Test Cases:
Expression Result Comment
=ISEVEN(2) True 2 is even, because (2 modulo 2) = 0
=ISEVEN(6) True 6 is even, because (6 modulo 2) = 0
=ISEVEN(2.1) True
=ISEVEN(2.5) True
=ISEVEN(2.9) True TRUNC(2.9)=2, and 2 is even.
=ISEVEN(3) False 3 is not even.
=ISEVEN(3.9) False TRUNC(3.9)=3, and 3 is not even.
=ISEVEN(-2) True
=ISEVEN(-2.1) True
=ISEVEN(-2.5) True
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 217 of 442
=ISEVEN(-2.9) True TRUNC(-2.9)=-2, and -2 is even.
=ISEVEN(-3) False
=ISEVEN(NA()) NA
=ISEVEN(0) True
See also ISODD
6.13.18 ISFORMULA
Summary: Return TRUE if the reference refers to a formula, else return FALSE
Syntax: ISFORMULA( Reference X )
Returns: Logical
Constraints: None
Semantics: If X refers to a cell whose value is computed by a formula, return TRUE(), else return
FALSE(). A formula itself may compute a constant; in that case it will still return TRUE() since it is
still a formula. Passing a non-reference, or a reference to more than one cell, is implementation-
defined.
anchor:ISFORMULA
Test Cases:
Expression Result Comment
=ISFORMULA([.B5]) True Simple formulas that produce Number are still formulas
=ISFORMULA([.B3]) True Simple formulas that produce Text are still formulas
=ISFORMULA([.C5]) False Cell constants are not formulas
=ISFORMULA([.C7]) False Cell constants are not formulas, even if they are dates
=ISFORMULA([.B9]) True Formulas that return an error are still formulas
See also ISTEXT, ISNUMBER
6.13.19 ISLOGICAL
Summary: Return TRUE if the parameter has type Logical, else return FALSE
Syntax: ISLOGICAL( Scalar X )
Returns: Logical
Constraints: None
Semantics: If X is of type Logical, returns TRUE, else FALSE. Evaluators that do not have a distinct
Logical type will return the same value ISNUMBER(X) would return.
anchor:ISLOGICAL
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 218 of 442
Test Cases:
Expression Result Comment
=ISLOGICAL(TRUE()) True Logical values return true.
=ISLOGICAL(FALSE()) True Logical values return true.
=ISLOGICAL("TRUE") False Text values are not logicals, even if they can be converted.
See also ISTEXT, ISNUMBER
6.13.20 ISNA
Summary: Return True if the parameter is of type NA, else return False.
Syntax: ISERR( Scalar X )
Returns: Logical
Constraints: None
Semantics: If X is NA, return True, else return False. Note that if X is a reference, the value being
referenced is considered. This function does not propagate Error values.
anchor:ISNA
Test Cases:
Expression Result Comment
=ISNA(1/0) False
Error values other than NA() return False
the error does not propagate.
=ISNA(NA()) True By definition
=ISNA(#N/A) True By definition
=ISNA("#N/A") False Text is not NA
=ISNA(1) False Numbers are not NA
See also ERROR.TYPE, ISERROR, ISERR, ISNUMBER, ISTEXT, NA
6.13.21 ISNONTEXT
Summary: Return TRUE if the parameter does not have type Text, else return FALSE
Syntax: ISNONTEXT( Scalar X )
Returns: Logical
Constraints: None
Semantics: If X is of type Text, returns FALSE, else TRUE. If X is a reference, examines what X
references. References to empty cells are NOT considered Text, so a reference to an empty cell will
return TRUE. Empty Cell 4.7
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 219 of 442
ISNONTEXT(X) is equivalent to NOT(ISTEXT(X))
anchor:ISNONTEXT
Test Cases:
Expression Result Comment
=ISNONTEXT(1) True Numbers are not text
=ISNONTEXT(TRUE()
)
True Logical values are not text.
=ISNONTEXT("1") False
Text values are text, even if they can be converted into a
number.
=ISNONTEXT([.B7]) False B7 is a cell with text
=ISNONTEXT([.B9]) True B9 is an error, thus not text
=ISNONTEXT([.B8]) True B8 is a blank cell, so this will return TRUE
See also ISNUMBER, ISLOGICAL, ISTEXT
6.13.22 ISNUMBER
Summary: Return TRUE if the parameter has type Number, else return FALSE
Syntax: ISNUMBER( Scalar X )
Returns: Logical
Constraints: None
Semantics: If X is of type Number, returns TRUE, else FALSE. Evaluators may not have a
distinguished Logical type; in such evaluators, ISNUMBER(TRUE()) is TRUE.
anchor:ISNUMBER
Test Cases:
Expression Result Comment
=ISNUMBER(1) True Numbers are numbers
=ISNUMBER("1") False
Text values are not numbers, even if they can be converted into a
number.
See also ISTEXT, ISLOGICAL
6.13.23 ISODD
Summary: Return TRUE if the value is even, else return FALSE
Syntax: ISODD( Number X )
Returns: Logical
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 220 of 442
Constraints: None
Semantics: First, compute X1=TRUNC(X). Then, if X1 is odd (a division by 2 has a remainder of 1),
return True, else return False. The result is implementation-defined if given a Logical value; an
evaluator may return either an Error or the result of converting the Logical value to a Number (per
Conversion to Number ).
anchor:ISODD
Test Cases:
Expression Result Comment
=ISODD(3) True 3 is odd, because (3 modulo 2) = 0
=ISODD(5) True 5 is odd, because (5 modulo 2) = 0
=ISODD(3.1) True TRUNC(3.1)=3, and 3 is odd
=ISODD(3.5) True
=ISODD(3.9) True TRUNC(3.9)=3, and 3 is odd.
=ISODD(4) False 3 is not even.
=ISODD(4.9) False TRUNC(3.9)=3, and 3 is not even.
=ISODD(-3) True
=ISODD(-3.1) True
=ISODD(-3.5) True
=ISODD(-3.9) True TRUNC(-3.9)=-3, and -3 is odd.
=ISODD(-4) False
=ISODD(NA()) NA
=ISODD(0) False
=ISODD(1) True
=ISODD(2) False
=ISODD(2.9) False
See also ISEVEN
6.13.24 ISREF
Summary: Return True if the parameter is of type reference, else return False.
Syntax: ISREF( Any X )
Returns: Logical
Constraints: None
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 221 of 442
Semantics: If X is of type Reference or ReferenceList, return True, else return False. Note that
unlike nearly all other functions, when given a reference this function does not then examine the
value being referenced. Some functions and operators return references, and thus ISREF will return
True when given their results. X may be a ReferenceList, in which case ISREF returns True.
anchor:ISREF
Test Cases:
Expression Result Comment
=ISREF([.B3]) True
=ISREF([.B3]:
[.C4])
True The range operator produces references
=ISREF(1) False Numbers are not references
=ISREF("A1") False
Text is not a reference, even if it looks a little
like one
=ISREF(NA()) NA Errors propagate through this function
See also ISNUMBER, ISTEXT
6.13.25 ISTEXT
Summary: Return TRUE if the parameter has type Text, else return FALSE. If X is a reference,
examines what X references. References to empty cells are NOT considered Text, so a reference to
a empty cell will return FALSE. Empty Cell 4.7
ISTEXT(X) is equivalent to NOT(ISNONTEXT(X)).
Syntax: ISTEXT( Scalar X )
Returns: Logical
Constraints: None
Semantics: If X is of type Text, returns TRUE, else FALSE. References to blank cells are NOT
considered Text.
anchor:ISTEXT
Test Cases:
Expression Result Comment
=ISTEXT(1) False Numbers are not text
=ISTEXT("1") True Text values are text, even if they can be converted into a number.
See also ISNONTEXT, ISNUMBER, ISLOGICAL
6.13.26 N
Summary: Return the number of a value.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 222 of 442
Syntax: N( Any X )
Returns: Text
Constraints: None
Semantics: If X is a Reference, it is first dereferenced to a scalar. Then its type is examined. If it is
of type Number, it is returned. If it is of type Logical, 1 is returned if TRUE else 0 is returned. It is
implementation-defined what happens if it is provided a Text value.
anchor:N
Test Cases:
Expression Result Comment
=N(6) 6 N does not change numbers.
=N(TRUE()) 1 Does convert logicals.
=N(FALSE()) 0 Does convert logicals.
See also T, VALUE
Note: Many public documents inadequately describe this function; in particular, few seem to
describe exactly what happens when text is provided. N("4") produces 0 in Excel, but 4 in Ooo2.
6.13.27 NA
Summary: Return the constant Error value #N/A.
Syntax: NA()
Returns: Error
Constraints: Shall have 0 parameters
Semantics: This function takes no arguments and returns the Error NA
anchor:NA
Test Cases:
Expression Result Comment
=ISERROR(NA()
)
True NA is an error.
=ISNA(NA()) True Obviously, if this doesn't work, NA() or ISNA() is broken.
=ISNA(5+NA()) True
NA propagates through various functions and operators, just like any
other error type.
See also ERROR.TYPE, ISERROR
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 223 of 442
6.13.28 NUMBERVALUE
Summary: Convert text to number, in a locale-independent way
Syntax: NUMBERVALUE( Text X [ ; Text DecimalSeparator [ ; Text GroupSeparator ] ] )
Returns: Number
Constraints: LEN(DecimalSeparator) = 1, DecimalSeparator shall not appear in GroupSeparator
Semantics: Converts given Text value X into Number. If X is a Reference, it is first dereferenced.
DecimalSeparator defines the character used as the decimal separator, for example "." (period) or
"," (comma). If this parameter is not given, only integer numbers are parsed.
GroupSeparator defines the character(s) used as grouping separator, for example "," (comma) or "."
(period). If this parameter is not given, only integer or decimal numbers containing the
DecimalSeparator are parsed. If this parameter is given, all characters contained are ignored in T if
each is surrounded by a digit on each side. If GroupSeparator contains " " U+0020 (SPACE),
U+0020 and U+00A0 (NO-BREAK SPACE) shall be equally treated.
If the supplied text X cannot be converted into a Number, an Error is returned.
Regardless of the current locale, the evaluator shall accept text representations that match this
regular expression when DecimalSeparator is "." (a period) and GroupSeparator is "," (a comma):
[+|-]?([0-9]+(,[0-9])*)?(\.[0-9]+)?(([eE][+-]?[0-9]+)|%)?
If, for example, DecimalSeparator is "," (a comma) and GroupSeparator is "." (a period), use the
expression above but swapping the comma for the period (so "." is ignored).
anchor:NUMBERVALUE
Rationale: This doesn't handle all possible number format of all locales, but it handles a large
number of locales while ensuring that processing is not dependent on the current locale. Early drafts
of this specification had a VALUEL, which accepted a locale parameter, but this turned out to be
unwieldy... so this alternative was proposed instead.
Test Cases:
Expression Result Comment
=NUMBERVALUE("6"; .) 6 VALUE converts text to numbers (unlike N).
=NUMBERVALUE("6,000.5"; .) 6000.5 Period works.
=NUMBERVALUE("6.000,5";,) 6000.5 Comma works
See also N, T, DATEVALUE, TIMEVALUE, VALUE
6.13.29 ROW
Summary: Returns the row number(s) of a reference
Syntax: ROW( [ Reference R ] )
Returns: Number
Constraints: AREAS(R) = 1
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 224 of 442
Semantics: Returns the row number of a reference. If no parameter is given, the current cell is
used. If a reference has multiple rows, an array of numbers is returned with all of the rows in the
reference.
anchor:ROW
Test Cases:
Expression Result Comment
=ROW([.B7]) 7
The second value of a cell reference is the
row number.
=ROW() 5
Row of current cell is default, here formula in
row 5.
{=ROW([.B2:.B4])} {2|3|4} Array with row numbers.
See also COLUMN, SHEET
Note: Testing the default row value is tricky the test case above simply ensure that it is legal to
have zero parameters. Real implementations actually have to get the row number correct, though of
course this is not hard to do.
6.13.30 ROWS
Summary: Returns the number of rows in a given range
Syntax: ROWS( Reference|Array R )
Returns: Number
Constraints: None
Semantics: Returns the number of rows in the range or array specified. The result is not dependent
on the cell content in the range.
anchor:ROWS
Test Cases:
Expression Result Comment
=ROWS([.C1]) 1 Single cell range contains one row.
=ROWS([.C1:.C4]) 4 Range with four rows.
=ROWS([.A4:.D100]) 97 Number of rows in range.
See also COLUMNS
Note: Removed tests for null range and sheet traversal works in other implementations. Only
checked OO. The null range gives an Error in Gnumeric and in Excel.
Note: Excel supports inline Arrays. OpenOffice.org 2 does not support inline arrays.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 225 of 442
6.13.31 SHEET
Summary: Returns the sheet number of the reference or the string representing a sheet name.
Syntax: SHEET( [ Text|Reference R ] )
Returns: Number >= 1
Constraints: R shall not contain a Source Location (5.8 References)
Semantics: Returns the 1 based sheet number of the given reference or sheet name.
Hidden sheets are not excluded from the sheet count.
If no parameter is given, the result is the sheet number of the sheet containing the formula.
If a Reference is given it is not dereferenced.
If the reference encompasses more than one sheet, the result is the number of the first sheet in the
range.
If a reference does not contain a sheet reference, the result is the sheet number of the sheet
containing the formula.
anchor:SHEET
Test Cases:
Expression Result Comment
=SHEET([.B7])>=1 True
If given, the sheet number of the reference is
used.
=SHEET("Sheet1")>=1 True
Given a sheet name, the sheet number is
returned.
See also COLUMN, ROW, SHEETS
6.13.32 SHEETS
Summary: Returns the number of sheets in a reference or current document
Syntax: SHEETS( [ Reference R ] )
Returns: Number >= 1
Constraints: R shall not contain a Source Location (5.8 References)
Semantics: Returns the number of sheets in the given reference.
If no parameter is given, the number of sheets in the document is returned.
Hidden sheets are not excluded from the sheet count.
anchor:SHEETS
Test Cases:
Expression Result Comment
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 226 of 442
=SHEETS([.B7]) 1
If given, the number of sheets in the
reference is used.
=SHEETS([Sheet1.B7:Sh
eet3.C9])
3
If given, the number of sheets in the
reference is used.
=SHEETS()>=1 True
Without a parameter, return the number of
sheets in this document.
See also COLUMNS, ROWS, SHEET
Note: These aren't rigorous tests, but they ensure that the function is defined and that it can be
called with and without a parameter.
6.13.33 TYPE
Summary: Returns a number indicating the type of the provided value.
Syntax: TYPE( Any value )
Returns: Number
Constraints: None
Semantics: Returns a number indicating the type of the value given:
Table 21 - TYPE
Value's Type TYPE Return
Number 1
Text 2
Logical 4
Error 16
Array 64
If a Reference is provided, the reference is first dereferenced, and any formulas are evaluated.
Note: Reliance on the return of 4 for TYPE() will impair the interoperability of a document containing
an expression that relies on that value.
anchor:TYPE
Test Cases:
Expression Result Comment
=TYPE(1+2) 1 Number has TYPE code of 1
=TYPE(Hi&there) 2 Text has TYPE 2
=TYPE(NA()) 16 Errors have TYPE 16.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 227 of 442
See also ERROR.TYPE
Note: We don't test for array here, because not all applications that support TYPE() support inline
arrays.
6.13.34 VALUE
Summary: Convert text to number
Syntax: VALUE( Text X )
Returns: Number
Constraints: None
Semantics: Converts given text value X into Number. If X is a Reference, it is first dereferenced.
VALUE is only specified if it is given a Text value or a Reference to a single cell containing a Text
value; it is implementation-defined what happens if VALUE is given neither a Text value nor a
Reference to a Text value. If the Text has a date, time, or datetime format, it is converted into a
serial Number. In many cases the conversion of a date or datetime format is locale-dependent.
If the supplied text X cannot be converted into a Number, an Error is returned.
Regardless of the current locale, an evaluator shall accept numbers matching this regular
expression (which does not include a decimal point character) and convert it into a Number. If the
value ends in %, it shall divide the number by 100:
[+-]? [0-9]+([eE][+-]?[0-9]+)?)%?
VALUE shall accept text representations of numbers in the current locale. In the en_US locale, an
evaluator shall accept decimal numbers matching this regular expression and convert it into a
Number (the leading $ is ignored; commas are ignored if they match the rule of a thousands
separator; if the value ends in %, it shall divide the number by 100):
[+-]?\$?([0-9]+(,[0-9]{3})*)?(\.[0-9]+)?(([eE][+-]?[0-9]+)|%)?
Note: Unfortunately, VALUE is locale-dependent for issues such as decimal points and the currency
format.
Evaluators shall accept accept fractional values matching the regular expression:
[+-]? [0-9]+ \ [0-9]+/[1-9][0-9]?
A leading minus sign is considered identifying a negative number for the entire value. There is a
space between the integer and the fractional portion; values between 0 and 1 can be represented
by using 0 for the integer part.
Evaluators shall support time values in at least the HH:MM and HH:MM:SS formats, where HH is a
1-2 digit value from 0 to 23, MM is a 1-2 digit value from 0 to 59, and SS is a 1-2 digit value from 0
to 59. The hour may be one or two digits when it is less than 10. VALUE converts time values into
Numbers ranging from 0 to 1, which is percentage of day that has elapsed by that time. Thus,
VALUE("2:00") is the same as 2/24. Evaluators should accept times with fractional seconds as well
when expressed in the form HH:MM:SS.ssss...
Evaluators shall accept textual dates in ISO 8601 format (YYYY-MM-DD), converting them into
serial numbers based on the current epoch. Evaluators shall, when running in the en_US locale,
accept the format MM/DD/YYYY .
In addition, in locale en_US, evaluators shall support the following formats (where YYYY is a 4-digit
year, YY a 2-digit year, MM a numerical month, DD a numerical day, mmm a 3-character
abbreviated alphabetical name, and mmmmm a full name):
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 228 of 442
Table 22 - VALUE
Format Example Comment
MM/DD/YYY
Y
5/21/2006 LOCALE-DEPENDENT; Long year format with slashes.
MM/DD/YY 5/21/06 LOCALE-DEPENDENT; Short year format with slashes
MM-DD-
YYYY
5-21-2006
LOCALE-DEPENDENT; Long year format with dashes (short year
may be supported, but it may also be used for years less than 100 .
mmm DD,
YYYY
Oct 29, 2006
LOCALE-DEPENDENT; Short alphabetic month day, year. Note:
mmm depends on the locale's language.
DD mmm
YYYY
29 Oct 2006 LOCALE-DEPENDENT; Short alphabetic day month year
mmmmm DD,
YYYY
October 29,
2006
LOCALE-DEPENDENT; Long alphabetic month day, year
DD mmmmm
YYYY
29 October
2006
LOCALE-DEPENDENT; Long alphabetic day month year
Evaluators should support other locales. Many conversions will vary by locale, including the decimal
point (comma or period), names of months, date formats (MM/DD vs. DD/MM), and so on. Dates in
particular vary by locale.
Evaluators shall support the datetime format, which is a date followed by a time, using either the
space character or the literal T character as the separator (the T is from ISO 8601). Evaluators
shall support at least the ISO date format in a datetime format; they may support other date formats
in a datetime format as well. Formats such as YYYY-MM-DD HH:MM and YYYY-MM-
DDTHH:MM:SS (where T is the literal character T) shall be accepted. The result of accepting a
datetime format shall be a representation of that specific time (without removing either the date or
the time of day, unlike DATEVALUE or TIMEVALUE).
Evaluators may accept other formats that will convert to numbers, and those conversions may be
locale-dependent, as long as they do not conflict with the above. Where no conversion is
determined, an Error is returned.
anchor:VALUE
Test Cases:
Expression Result Comment
=VALUE("6") 6 VALUE converts text to numbers (unlike N).
=VALUE("1E5") 100000 Works with exponential notation.
=VALUE("200%") 2 Optional %.
=VALUE("1.5") 1.5
LOCALE-DEPENDENT: Accepts fractional values. In
en_US, this is valid.
=VALUE("7 1/4") 7.25 Fractional part.
=VALUE("0 1/2") 0.5 Fractional part.
=VALUE("-1 1/2") -1.5 -1 1/2 is interpreted as -1.5, not as (-1)+(1 / 2).
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 229 of 442
=VALUE([.B3]) 7 VALUE converts references to text to numbers.
=VALUE("00:00") 0
VALUE converts time values to numbers between 0
and 1.
=VALUE("02:00")-2/24 0
VALUE converts time values to numbers between 0
and 1.
=VALUE("2:03")-(2/24)-(3/
(24*60))
0 Time value with hours and minutes.
=VALUE("2:03:05") -2/24-3/
(24*60) -5/(24*60*60)
0 Hours, minutes, and seconds.
=VALUE("3/32/2006") Error Invalid date yields an error (contrast this with DATE)
=VALUE("2/29/2006") Error
"False leap year" yields an error for 1901 and
beyond
=VALUE("2005-01-
02")=DATE(2005;1;2)
True VALUE converts dates into serial numbers.
=VALUE("2005-01-03 13:00")-
VALUE("2005-01-02 01:00")
1.5
Datetime values handled correctly, using space to
separate date from time. Note that VALUE can return
portions of a day, unlike DATEVALUE or
TIMEVALUE.
=VALUE("2005-01-03T13:00")-
VALUE("2005-01-02T01:00")
1.5
Datetime values handled correctly, using T to
separate date from time as defined by ISO 8601.
=VALUE("1/2/2005")=DATE(200
5;1;2)
True LOCALE-DEPENDENT; in en_US, this is true.
=VALUE("5/21/06")=DATE(2006
;5;21)
True
LOCALE-DEPENDENT; Short year format with
slashes
=VALUE("Oct 29,
2006")=DATE(2006;10;29)
True
LOCALE-DEPENDENT; Short alphabetic month day,
year
=VALUE("29 Oct
2006")=DATE(2006;10;29)
True
LOCALE-DEPENDENT; Short alphabetic day month
year
=VALUE("October 29,
2006")=DATE(2006;10;29)
True
LOCALE-DEPENDENT; Long alphabetic month day,
year
=VALUE("29 October
2006")=DATE(2006;10;29)
True
LOCALE-DEPENDENT; Long alphabetic day month
year
See also N, T, DATEVALUE, TIMEVALUE, NUMBERVALUE
Note: Some applications (such as Excel and Gnumeric) apply VALUE automatically when Text or a
reference to Text is provided, but a Number is required. Others, such as OOo2 and Lotus 1-2-3,
require explicit use of VALUE.
It's unfortunate that VALUE is locale-specific, even for ordinary numbers. NUMBERVALUE was
created to provide a way to deal with , vs. . as the decimal point.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 230 of 442
KSpread 1.4.2 incorrectly computes VALUE("6") as 0; it should be 6. Tomas Mecir reports that as of
January 9, 2006, the development version of KSpread (in CVS) computes VALUE("6") correctly
instead.
Note: Short year formats with dashes, like 5-21-06, aren't required here, because if an
implementation supports years before 100 they're not always distinguishable. For more on date
conversion, see "Excel 2003 Formulas" page 144-145.
Note: Lotus 1-2-3 and Quattro Pro don't support ISO date format YYYY-MM-DD. Excel,
OpenOffice.org, Gnumeric, SheetToGo, and KOffice all do.
6.14 Lookup Functions
6.14.1 General
These functions look up information. Note that IF() can be considered a trivial lookup function, but it
is listed as a logical function instead.
6.14.2 ADDRESS
Summary: Returns a cell address (reference) as text
Syntax: ADDRESS( Integer Row ; Integer Column [ ; Integer Abs = 4 [ ; Logical A1 = TRUE() [ ;
Text Sheet ] ] ] )
Returns: Text
Constraints: Row >= 1, Column >= 1, 1 <= Abs <= 4; A1 = TRUE(). Evaluators may evaluate
expressions that do not meet the constraint A1 = TRUE().
Semantics: Returns a cell address (reference) as text. The text does not include the surrounding
[...] of a reference. If a Sheet name is given, the sheet name in the text returned is followed by a .
and the column/row reference if A1 is TRUE, or a ! and the column/row reference if A1 is FALSE;
otherwise no . respectively ! is included. Columns are identified using uppercase letters. The
value of Abs determines if the column and/or row is absolute or relative. The value of A1 determines
if A1 reference style or R1C1 reference style is used.
Table 23 - ADDRESS
Abs Meaning A1 = TRUE() A1 = FALSE()
1 fully absolute $A$1 R1C1
2 row absolute, column relative A$1 R1C[1]
3 row relative, column absolute $A1 R[1]C1
4 fully relative A1 R[1]C[1]
Note that the INDIRECT function accepts this format.
anchor:ADDRESS
Test Cases:
Expression Result Comment
=ADDRESS(5; 3; 2; TRUE(); Sheet1.C$5 Example showing all parameters
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 231 of 442
"Sheet1")
=ADDRESS(5; 3) C5 Last three parameters can be omitted
See also INDIRECT
NOTE: Excel has a subtly incompatible format for the sheet text, using an exclamation mark as the
sheet name separator. For this reason in the non-A1 R1C1 case the exclamation mark was
specified, because applications that support the R1C1 reference style usually also support the
exclamation mark.
6.14.3 CHOOSE
Summary: Uses an index to return a value from a list of values.
Syntax: CHOOSE( Integer Index ; { Any Value }
+
)
Returns: Any
Constraints: Returns an Error if Index < 1 or if there is no corresponding value in the list of Values.
Semantics: Uses Index to determine which value, from a list of values, to return. If Index is 1,
CHOOSE returns the first Value; if Index is 2, CHOOSE returns the second value, and so on. Note
that the Values may be formula expressions. Expression paths of parameters other than the one
chosen are not calculated or evaluated for side effects.
anchor:CHOOSE
Test Cases:
Expression Result Comment
=CHOOSE(3;"Apple";"Orange";"Grape";"P
erry")
"Grape" Simple selection.
=CHOOSE(0;"Apple";"Orange";"Grape";"P
erry")
Error Index has to be at least 1.
=CHOOSE(5;"Apple";"Orange";"Grape";"P
erry")
Error Index can't refer to non-existent entry.
=CHOOSE(2;SUM([.B4:.B5]);SUM([.B5])) 3 Simple selection, using a set of formulas.
=SUM(CHOOSE(2;[.B4:.B5];[.B5])) 3 CHOOSE can pass references
See also IF
Note: OOo2 produces errors if the index is too small or large, but the index cannot be captured by
ISERROR. This is probably a defect in ISERROR. Currently this ISERROR requirement assigned to
level 2, to allow automated tests to work correctly.
6.14.4 GETPIVOTDATA
Summary: Return a value from a data pilot table.
Syntax: GETPIVOTDATA( Text DataField ; Reference Table { ; Text Field ; Scalar Member }
*
)
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 232 of 442
Note: This function knows two different syntaxes. This version of the syntax is distinguished by the
second parameter Table being a Reference.
Returns: Any
Semantics: Returns a single result from the calculation of a data pilot table.
The data pilot table is selected by Table, which is a reference to a cell or cell range that's within a
data pilot table or contains a data pilot table. If the cell range contains several data pilot tables, the
last one in the order of <table:data-pilot-table> elements in the file is used.
DataField selects one of the data pilot table's data fields. It can be the name of the source column,
or the given name of the data field (such as Sum of Sales).
If no Field/Member pairs are given, the grand total is returned. Otherwise, each pair adds a
constraint that the result shall satisfy. Field is the name of a field from the data pilot table. Member
is the name of a member (item) from that field. If a member is a number, Member can alternatively
be its numerical value.
If the data pilot table contains only a single result value that fulfills all of the constraints, or a subtotal
result that summarizes all matching values, that result is returned. If there is no matching result, or
several ones without a subtotal for them, an Error is returned. These conditions apply to results that
are included in the data pilot table. If the source data contains entries that are hidden by settings of
the data pilot table, they are ignored. The order of the Field/Member pairs is not significant. Field
and member names are case-insensitive.
If no constraint for a page field is given, the field's selected value is implicitly used. If a constraint for
a page field is given, it shall match the field's selected value, or an Error is returned.
Subtotal values from the data pilot table are only used if they use the function auto (except when
specified in the constraint, see below).
Alternative syntax: GETPIVOTDATA( Reference Table ; Text Constraints )
For compatibility, a second syntax is allowed. Table has the same meaning as above. This version
of the syntax is distinguished by the first parameter Table being a Reference.
Constraints is a space-separated list. Entries can be quoted (single quotes). One of the entries can
be the data field name. The data field name can be left out if the data pilot table contains only one
data field, otherwise it shall be present. Each of the other entries specifies a constraint in the form
Field[Member] (with literal characters [ and ]), or only Member if the member name is unique within
all fields that are used in the data pilot table. A function name can be added in the form
Field[Member;Function], which will cause the constraint to match only subtotal values which use
that function. The possible function names are the same as in the table:function attribute of
the <table:data-pilot-subtotal> element, case-insensitive.
anchor:GETPIVOTDATA
Test Cases:
TBD: if we wanted test cases for this, we'd have to have a sufficient data table structure, create a
DataPilot table from it, and then use the test cases with that.
6.14.5 HLOOKUP
Summary: Look for a matching value in the first row of the given table, and return the value of the
indicated row.
Syntax: HLOOKUP( Any Lookup ; Reference|Array DataSource ; Integer Row [ ; Logical
RangeLookup = TRUE() ] )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 233 of 442
Returns: Any
Constraints: Row >= 1; Searched portion of DataSource shall not include Logical values.
Evaluators may evaluate expressions that do not meet the constraint that the searched portion of a
DataSource not include Logical values.
Semantics:
If RangeLookup is omitted or TRUE or not 0, the first row of DataSource is assumed to be sorted in
ascending order, with smaller numbers before larger ones, smaller text values before larger ones
(e.g., "A" before "B", and "B" before "BA"), and False before True. If the types are mixed, Numbers
are sorted before Text, and Text before Logicals; evaluators without a separate Logical type may
include a Logical as a Number. The lookup will try to match an entry of value Lookup. If none is
found the largest entry less than Lookup is taken as a match. From a sequence of identical values
<= Lookup the last entry is taken. If there is no data less than or equal to Lookup, the #N/A Error is
returned. If Lookup is of type Text and the value found is of type Number, the #N/A Error is returned.
If DataSource is not sorted, the result is undetermined and implementation-dependent. In most
cases it will be arbitrary and just plain wrong due to binary search algorithms.
If RangeLookup is FALSE or 0, DataSource does not need to be sorted and an exact match is
searched. Each value in the first row of DataSource is examined in order (starting at the left) until its
value matches Lookup.
Both methods, if there is a match, return the corresponding value in row Row, relative to the
DataSource, where the topmost row in DataSource is 1.
The values returned may vary depending upon the HOST-USE-REGULAR-EXPRESSIONS or
HOST-USE-WILDCARDS properties. 3.4
anchor:HLOOKUP
Test Cases:
Expression Result Comment
=HLOOKUP("Rev"; [.B18:.I31];2;FALSE()) 13 First Rev data entry.
=HLOOKUP("NOSUCHNAME";
[.B18:.I31];2;FALSE())
Error No such value.
=HLOOKUP("Rev"; [.B18:.I31];2) 13
The result is
undetermined since the
first row is not sorted
ascending!
Binary search algorithms
may accidentally deliver
the correct result because
in this case "Rev" is the
last entry and they inspect
outermost values first.
=HLOOKUP("NOSUCHNAME"; [.B18:.I31];2)
12 Mar
2005
The result is
undetermined since the
first row is not sorted
ascending!
TBD: test cases with string lookups and RangeLookup=TRUE (or omitted) aren't that useful for
understanding the functionality, numeric lookups in a set of classifications like those used in
VLOOKUP would be better suited.
See also INDEX, MATCH, OFFSET, VLOOKUP
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 234 of 442
6.14.6 INDEX
Summary: Returns a value using a row and column index value (and optionally an area index).
Syntax: INDEX( ReferenceList|Array DataSource ; [ Integer Row ] [ ; [ Integer Column ] ] [ ; Integer
AreaNumber = 1 ] )
Returns: Any
Constraints: Row >= 0, Column >= 0,
1 <= AreaNumber <= number of references in DataSource if that is a ReferenceList, else
AreaNumber = 1
Semantics:
Given a DataSource, returns the value at the given Row and Column (starting numbering at 1,
relative to the top left of the DataSource) of the given area AreaNumber. If AreaNumber is not
given, it defaults to 1 (the first and possibly only area). This function is essentially a two-dimensional
version of CHOOSE, which does not accept range parameters.
If Row is omitted or an empty parameter (two consecutive ;; semicolons) or 0, an entire column of
the given area AreaNumber in DataSource is returned. If Column is omitted or an empty parameter
(two consecutive ;; semicolons) or 0, an entire row of the given area AreaNumber in DataSource is
returned. If both, Row and Column, are omitted or empty or 0, the entire given area AreaNumber is
returned.
If DataSource is a one-dimensional column vector, Column is optional or can be omitted as an
empty parameter (two consecutive ;; semicolons). If DataSource is a one-dimensional row vector,
Row is optional, which effectively makes Row act as the column offset into the vector, or can be
omitted as an empty parameter (two consecutive ;; semicolons).
If Row or Column have a value greater than the dimension of the corresponding given area
AreaNumber, an Error is returned.
anchor:INDEX
Test Cases:
Expression Result Comment
=INDEX([.B3:.C5];2;1) 2 Simple index into row 2, column 1.
=INDEX([.B3:.C5]~[.B6:.C8];2;1;2) "Hello" Index into row 2, column 1, of area 2
TODO: test cases for the quite complex semantics.
See also AREAS, CHOOSE
6.14.7 INDIRECT
Summary: Return a reference given a string representation of a reference
Syntax: INDIRECT( Text Ref [ ; Logical A1 = TRUE() ] )
Returns: Reference
Constraints: Ref is valid reference
Semantics: Given text for a reference (such as A3), returns a reference. If A1 is False, it is
interpreted as an R1C1 reference style. For interoperability, if the Ref text includes a sheet name,
evaluators should be able to parse both, the . dot and the ! exclamation mark, as the sheet name
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 235 of 442
separator. If evaluators support the A1=FALSE() case of the ADDRESS function and include the !
exclamation mark as the sheet name separator, evaluators shall correctly parse that in the
A1=FALSE() case of this INDIRECT function. Evaluators shall correctly parse the . dot as the
sheet name separator in the A1=TRUE() case.
anchor:INDIRECT
Test Cases:
Expression Result Comment
=INDIRECT(B & 4) 2 Simple lookup
=SUM(INDIRECT(B4:
B5))
5
INDIRECT can create
references to ranges
=ISREFERENCE(INDI
RECT(B4))
True
INDIRECT returns a reference
value.
See also ADDRESS
TODO: Should we discuss external files? Here Excel and OOo differ. It's probably perfectly
reasonable to have a function that can accept either format, which would be more general.
6.14.8 LOOKUP
Summary: Look for criterion in an already-sorted array, and return a corresponding result
Syntax: LOOKUP( Any Find ; ForceArray Reference|Array Searched [ ; ForceArray Reference|
Array Results ] )
Returns: Any
Constraints: The searched portion of Searched shall be sorted in ascending order; if provided,
Results shall have the same length as Searched. The searched portion of Searched shall not
include Logical values. Evaluators may evaluate expressions that do not meet the constraint that
the searched portion of a Searched not include Logical values.
Semantics: This function searches for Find in a row or column of the previously-sorted array
Searched and returns a corresponding value. The match is the largest value in the row/column of
Searched that is less than or equal to Find (so an exact match is always preferred over inexact
ones). From a sequence of identical values <= Find the last entry is taken. If Find is smaller than the
smallest value in the first row or column (depending on the array dimensions), LOOKUP returns the
#N/A Error. If Find is of type Text and the value found is of type Number, the #N/A Error is returned.
The searched portion of Searched shall be sorted in ascending order, and so that values of type
Number precede values of type Text if both types are included (e.g., -2, 0, 2, A, B).
Note: In Excel, mixed types must be sorted as Number, Text, and Logical (in that order). This isn't
possible in general if Logical is not a distinct type, which is why the portable constraint is stated this
way.
There are two major uses for this function; the 3-parameter version (vector) and the 2-parameter
version (non-vector array).
Note: Interoperability is improved by use of HLOOKUP or VLOOKUP in expressions over LOOKUP.
When given two parameters, Searched is first examined:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 236 of 442
If Searched is square or is taller than it is wide (more rows than columns), LOOKUP searches in
the first column (similar to VLOOKUP), and returns the corresponding value in the last column.
If Searched covers an area that is wider than it is tall (more columns than rows), LOOKUP
searches in the first row (similar to HLOOKUP), and returns the corresponding value in the last
row.
When given 3 parameters, Results shall be a vector (either a row or a column) or an Error is raised.
The function determines the index of the match in the first column respectively row of Searched,
and returns the value in Results with the same index.
Searched is first examined:
If Searched is square or is taller than it is wide (more rows than columns), LOOKUP searches in
the first column (similar to VLOOKUP).
If Searched covers an area that is wider than it is tall (more columns than rows), LOOKUP
searches in the first row (similar to HLOOKUP).
The lengths of the search vector and the result vector do not need to be identical. When the match
position falls outside the length of the result vector, an Error is returned if the result vector is given
as an array object. If it is a cell range, it gets automatically extended to the length of the searched
vector, but in the direction of the result vector. If just a single cell reference was passed, a column
vector is generated. If the cell range cannot be extended due to the sheet's size limit, then the #N/A
Error is returned.
The values returned may vary depending upon the HOST-USE-REGULAR-EXPRESSIONS or
HOST-USE-WILDCARDS properties. 3.4
anchor:LOOKUP
Test Cases:
Expression Result Comment
=LOOKUP(6;
[.B51:.B57];
[.C51:.C57])
11 Simple lookup
=LOOKUP(6;
[.B51:.B57];
[.C52:.C58])
12
Result vector doesn't need to
align with search vector
=LOOKUP(6;
[.B51:.C57])
11 Two-parameter version
=LOOKUP(0;
[.B51:.B57];
[.C52:.C58])
Error Too small produces Error
=LOOKUP(6.1;
[.B51:.B57];
[.C51:.C57])
11
Lookup if not exact, largest
available that is smaller than
value to Find
See also HLOOKUP, INDEX, MATCH, OFFSET, VLOOKUP
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 237 of 442
6.14.9 MATCH
Summary: Finds a Search item in a sequence, and returns its position (starting from 1).
Syntax: MATCH( Scalar Search ; Reference|Array SearchRegion [ ; Integer MatchType = 1 ] )
Returns: Any
Constraints: -1 <= MatchType <= 1; The searched portion of SearchRegion shall not include
Logical values. Evaluators may evaluate expressions that do not meet the constraint that the
searched portion of a SearchRegion not include Logical values.
SearchRegion shall be a vector (a single row or column)
Semantics:
MatchType = -1 finds the smallest value that is greater than or equal to Search in a
SearchRegion where values are sorted in descending order. From a sequence of identical
values >= Search the last value is taken. If no value >= Search exists, the #N/A Error is
returned. If Search is of type Number and the value found is of type Text, the #N/A Error is
returned.
MatchType = 0 finds the first value that is equal to Search. Values in SearchRegion do not need
to be sorted. If no value equal to Search exists, the #N/A Error is returned.
MatchType = 1 or omitted finds the largest value that is less than or equal to Search in a
SearchRegion where values are sorted in ascending order. From a sequence of identical values
<= Search the last value is taken. If no value <= Search exists, the #N/A Error is returned. If
Search is of type Text and the value found is of type Number, the #N/A Error is returned.
If a match is found, MATCH returns the relative position (starting from 1). For Text the comparison is
case-insensitive. MatchType determines the type of search; if MatchType is 0, the SearchRegion
shall be considered unsorted, and the first match is returned. If MatchType is 1, the SearchRegion
may be assumed to be sorted in ascending order, with smaller Numbers before larger ones, smaller
Text values before larger ones (e.g., "A" before "B", and "B" before "BA"), and False before True. If
the types are mixed, Numbers are sorted before Text, and Text before Logicals; evaluators without a
separate Logical type may include a Logical as a Number. If MatchType is -1, then SearchRegion
may be assumed to be sorted in descending order (the opposite of the above). If MatchType is 1 or
-1, evaluators may use binary search or other techniques so that they do not need to examine every
value in linear order. MatchType defaults to 1.
The values returned may vary depending upon the HOST-USE-REGULAR-EXPRESSIONS or
HOST-USE-WILDCARDS properties. 3.4
anchor:MATCH
Test Cases:
Expression Result Comment
=MATCH("HELLO";[.B3:.B7];0) 5 Simple MATCH().
=MATCH(0;[.B51:.B57]) =NA()
No value less than or equal to Search in
sorted numerical data.
=MATCH(6.1;[.B51:.B57]) 3
In sorted numerical data, 6 is the largest
value that is less than or equal to
Search
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 238 of 442
See also HLOOKUP, OFFSET, VLOOKUP
TBD: Do we need test cases for sorted descending as well? Assuming not, because it's obvious.
6.14.10 MULTIPLE.OPERATIONS
Summary: Executes a formula expression while substituting a row reference and a column
reference.
Syntax: MULTIPLE.OPERATIONS( Reference FormulaCell ; Reference RowCell ; Reference
RowReplacement [ ; Reference ColumnCell ; Reference ColumnReplacement ] )
Returns: Any
Semantics:
FormulaCell reference to the cell that contains the formula expression to
calculate.
RowCell reference that is to be replaced by RowReplacement.
RowReplacement reference that replaces RowCell.
ColumnCell reference that is to be replaced by ColumnReplacement.
ColumnReplacement reference that replaces ColumnCell.
MULTIPLE.OPERATIONS executes the formula expression pointed to by FormulaCell and all
formula expressions it depends on while replacing all references to RowCell with references to
RowReplacement respectively all references to ColumnCell with references to
ColumnReplacement.
If calls to MULTIPLE.OPERATIONS are encountered in dependencies, replacements of target cells
shall occur in queued order, with each replacement using the result of the previous replacement.
Note: The function may be used to create tables of expressions that depend on two input
parameters.
Example: FormulaCell is B5, RowCell is B3, ColumnCell is B2
Table 24 - MULTIPLE.OPERATIONS
col_B col_C col_D col_E col_F
row_2 1 1 2 3
row_3 1 1
=MULTIPLE.OPER
ATIONS($B$5;$B$3
;$C3;$B$2;D$2)
=MULTIPLE.OPER
ATIONS($B$5;$B$3
;$C3;$B$2;E$2)
=MULTIPLE.OPER
ATIONS($B$5;$B$3
;$C3;$B$2;F$2)
row_4 =B2+B3 2
=MULTIPLE.OPER
ATIONS($B$5;$B$3
;$C4;$B$2;D$2)
=MULTIPLE.OPER
ATIONS($B$5;$B$3
;$C4;$B$2;E$2)
=MULTIPLE.OPER
ATIONS($B$5;$B$3
;$C4;$B$2;F$2)
row_5 =B2*B3+B4 3
=MULTIPLE.OPER
ATIONS($B$5;$B$3
;$C5;$B$2;D$2)
=MULTIPLE.OPER
ATIONS($B$5;$B$3
;$C5;$B$2;E$2)
=MULTIPLE.OPER
ATIONS($B$5;$B$3
;$C5;$B$2;F$2)
4
=MULTIPLE.OPER
ATIONS($B$5;$B$3
;$C6;$B$2;D$2)
=MULTIPLE.OPER
ATIONS($B$5;$B$3
;$C6;$B$2;E$2)
=MULTIPLE.OPER
ATIONS($B$5;$B$3
;$C6;$B$2;F$2)
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 239 of 442
Result:
Table 25 - MULTIPLE.OPERATIONS
col_B col_C col_D col_E col_F
row_2 1 1 2 3
row_3 1 1 3 5 7
row_4 2 2 5 8 11
row_5 3 3 7 11 15
4 9 14 19
Note that although only cell B5 is passed as the FormulaCell parameter, also the references to B2
and B3 of the formula in cell B4 are replaced, because B5 depends on B4.
anchor:MULTIPLE.OPERATIONS
Test Cases:
TODO: test cases; how do we want to define the table layout that would be helpful here?
Expression Result Comment
See also
Note: Though OpenOffice.org allows manual input of the formula, it is usually created from an area
selection by an UI dialog that asks for the positions of FormulaCell, RowCell and ColumnCell. The
positions of RowReplacement and ColumnReplacement are generated from the cell's position
containing the MULTIPLE.OPERATIONS formula and its intersection with the leftmost row /
uppermost column of the area selected. The absolute and relative references are generated such
that expanding the table with new values and formulas can be easily done by adding new rows and
columns with values and simply copying one formula cell to the clipboard and pasting it onto the
new area.
In Excel 2003 the function's name is TABLE and takes just 2 parameters, corresponding to RowCell
and ColumnCell. Manual input of the expression or extending its cell range is not accepted by Excel.
The formula is generated by a dialog and is always generated as a matrix formula. The
FormulaCell's position is implicitly assumed to be the upper left cell of the area selected. The
RowReplacement and ColumnReplacement is implicitly taken from the cell's position containing the
TABLE formula and its intersection with the leftmost row / uppermost column of the area selected.
6.14.11 OFFSET
Summary: Modifies a reference's position and dimension.
Syntax: OFFSET( Reference reference ; Integer rowOffset ; Integer columnOffset [ ; [ Integer
newHeight ] [ ; [ Integer newWidth ] ] ] )
Returns: Reference
Constraints: newWidth > 0; newHeight > 0
The modified reference shall be in a valid range, starting from column/row one to the maximum
column/row.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 240 of 442
Semantics: Shifts reference by rowOffset rows and by columnOffset columns. Optionally, the
dimension can be set to newWidth and/or newHeight, if omitted the width/height of the original
reference is taken. Note that newHeight may be empty (two consecutive semicolons ;;) followed by
a given newWidth argument. Returns the modified reference.
anchor:OFFSET
Test Cases:
Expression Result Comment
=OFFSET( [.A1]; 3; 1) 2 Positive shift.
=OFFSET( [.D6]; -2; -1) 4 Negative shift.
=SUM( OFFSET( [.A1]; 1; 3; 2 ) ) 5 New width.
=SUM( OFFSET( [.A1]; 1; 3; 2; 2 ) ) 14 New width and height.
=OFFSET( [.A1]; 1; 1; 0 ) Error newWidth must be > 0
=OFFSET( [.A1]; 1; 3; 1; 0 ) Error newHeight must be > 0
=SUM(OFFSET([.A14:.A17];0;1;;2)) 20
Shifted by one column.
Same height, new width.
Note empty height parameter.
=SUM(OFFSET([.A14:.B17];0;1;2;)) 10
Shifted by one column.
New height, same width.
Note empty width parameter.
=SUM(OFFSET([.A14:.B17];0;1;;)) 20
Shifted by one column.
Same height, same width.
Note empty height and width parameters,
the syntax does allow this.
=SUM(OFFSET([.A14:.B17];0;1)) 20
The same as above, only with omitted
parameters.
Shifted by one column.
Same height, same width.
See also COLUMN, COLUMNS, ROW, ROWS
6.14.12 VLOOKUP
Summary: Look for a matching value in the first column of the given table, and return the value of
the indicated column.
Syntax: VLOOKUP( Any Lookup ; Reference|Array DataSource ; Integer Column [ ; Logical
RangeLookup = TRUE() ] )
Returns: Any
Constraints: Column >= 1; The searched portion of DataSource shall not include Logical values.
Evaluators may evaluate expressions that do not meet the constraint that the searched portion of a
DataSource not include Logical values.
Semantics:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 241 of 442
If RangeLookup is omitted or TRUE or not 0, the first column of DataSource is assumed to be
sorted in ascending order, with smaller Numbers before larger ones, smaller Text values before
larger ones (e.g., "A" before "B", and "B" before "BA"), and False before True. If the types are
mixed, Numbers are sorted before Text, and Text before Logicals; evaluators without a separate
Logical type may include a Logical as a Number. The lookup will try to match an entry of value
Lookup. From a sequence of identical values <= Lookup the last entry is taken. If none is found the
largest entry less than Lookup is taken as a match. If there is no data less than or equal to Lookup,
the #N/A Error is returned. If Lookup is of type Text and the value found is of type Number, the #N/A
Error is returned. If DataSource is not sorted, the result is undetermined and implementation-
dependent. In most cases it will be arbitrary and just plain wrong due to binary search algorithms.
If RangeLookup is FALSE or 0, DataSource does not need to be sorted and an exact match is
searched. Each value in the first column of DataSource is examined in order (starting at the top)
until its value matches Lookup. If no value matches, the #N/A Error is returned.
Both methods, if there is a match, return the corresponding value in column Column, relative to the
DataSource, where the leftmost column in DataSource is 1.
The values returned may vary depending upon the HOST-USE-REGULAR-EXPRESSIONS or
HOST-USE-WILDCARDS properties. 3.4
anchor:VLOOKUP
Test Cases:
Expression Result Comment
=VLOOKUP("Ursa Major";
[.B19:.I31];2;FALSE())
6 Table states Ursa Major has 6 bright stars.
=VLOOKUP("Ursa Major";
[.B19:.I31];4;FALSE())
"Uma" Table states Ursa Major has abbreviation Uma.
=VLOOKUP(2;
[.C19:.I31];3;FALSE())
"Cmi"
Can match numbers as well as text. Canis Minor
is first in table (starting from top).
=VLOOKUP("NoSuchConstellation"
; [.B19:.I31];4;FALSE())
Error Error returned if not found.
=VLOOKUP(2; [.C19:.I31];3) "Cmi"
The result is arbitrary because column C (Bright
Stars) is not sorted! It may match or it may not!
=VLOOKUP("NoSuchConstellation"
; [.B19:.I31];4)
"Her"
Column B (Constellation) is sorted. "Hercules" is
matched because it is the largest value less than
or equal to "NoSuchConstellation", the next larger
value would had been "Orion".
=VLOOKUP(0;[.B51:.B57];2) Error
No value less than or equal to Lookup in sorted
numerical data.
=VLOOKUP(6.1;[.B51:.B57];2) 11
In sorted numerical data, 6 is the largest value
that is less than or equal to Lookup.
See also HLOOKUP, INDEX, MATCH, OFFSET
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 242 of 442
6.15 Logical Functions
6.15.1 General
The logical functions are the constants TRUE() and FALSE(), the functions that compute Logical
values NOT(), AND(), and OR(), and the conditional function IF(). The OpenDocument specification
mentions "logical operators"; these are another name for the logical functions.
Note that because of Error values, any logical function that accepts parameters can actually
produce TRUE, FALSE, or an Error value, instead of TRUE or FALSE.
These are not bitwise operations, e.g., AND(12;10) produces TRUE(), not 8. See the bit operation
functions for bitwise operations.
6.15.2 AND
Summary: Compute logical AND of all parameters.
Syntax: AND( { Logical|NumberSequenceList L }
+
)
Returns: Logical
Constraints: Shall have 1 or more parameters
Semantics: Computes the logical AND of the parameters. If all parameters are True, returns True; if
any are False, returns False. When given one parameter, this has the effect of converting that one
parameter into a Logical value. When given zero parameters, evaluators may return a Logical value
or an Error.
Also in array context a logical AND of all arguments is computed, range or array parameters are not
evaluated as a matrix and no array is returned. This behavior is consistent with functions like SUM.
To compute a logical AND of arrays per element use the * operator in array context.
anchor:AND
Note: Excel 2000, OpenOffice.org 2.0 and Gnumeric 1.4.3 consider AND() with no parameters an
error, Kspread 1.4.2 does not.
Test Cases:
Expression Result Comment
=AND(FALSE();FALSE()) False Simple AND.
=AND(FALSE();TRUE()) False Simple AND.
=AND(TRUE();FALSE()) False Simple AND.
=AND(TRUE();TRUE()) True Simple AND.
=AND(TRUE();NA()) NA Returns an error if given one.
=AND(1;TRUE()) True Nonzero considered TRUE.
=AND(0;TRUE()) False Zero considered FALSE.
=AND(TRUE();TRUE();TRUE()) True More than two parameters okay.
=AND(TRUE()) True One parameter okay - simply returns it.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 243 of 442
TBD: Implementations of AND and OR do NOT short-circuit on True and False, because they look
for error conditions and propagate them. For example, on Excel: AND(FALSE(), #NA) is #NA.
Should the "do not short-circuit" rule be REQUIRED? Should short-circuiting be PERMITTED? If
short-circuiting is not required, should short-circuiting versions of AND() and OR() be defined, e.g.,
ANDSC() and ORSC()?
See also OR, IF
6.15.3 FALSE
Summary: Returns constant FALSE
Syntax: FALSE()
Returns: Logical
Constraints: Shall have 0 parameters
Semantics: Returns logical constant FALSE. This may be a Number or a distinct type.
anchor:FALSE
Test Cases:
Expression Result Comment
=FALSE() False Constant
=IF(ISNUMBER(FALSE());
FALSE()=0;FALSE())
FALSE
Applications that implement Logical values as
0/1 must map TRUE() to 1
2+FALSE() 2 TRUE converts to 1 in Number context
See also TRUE, IF
6.15.4 IF
Summary: Return one of two values, depending on a condition
Syntax: IF( Logical Condition [ ; [ Any IfTrue ] [ ; [ Any IfFalse ] ] ] )
Returns: Any
Constraints: None.
Semantics: Computes Condition. If it is TRUE, it returns IfTrue, else it returns IfFalse. If there is
only 1 parameter, IfTrue is considered to be TRUE(). If there are less than 3 parameters, IfFalse is
considered to be FALSE(). Thus the 1 parameter version converts Condition into a Logical value. If
there are 2 or 3 parameters but the second parameter is null (two consecutive ;; semicolons),
IfFalse is considered to be 0. If there are 3 parameters but the third parameter is null, IfFalse is
considered to be 0. This function only evaluates IfTrue, or ifFalse, and never both; that is to say, it
short-circuits.
anchor:IF
Test Cases:
Expression Result Comment
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 244 of 442
=IF(FALSE();7;8) 8 Simple if.
=IF(TRUE();7;8) 7 Simple if.
=IF(TRUE();"HI";8) ="HI"
Can return strings, and the two sides need not have equal
types
=IF(1;7;8) 7 A non-zero is considered true.
=IF(5;7;8) 7 A non-zero is considered true.
=IF(0;7;8) 8 A zero is considered false.
=IF(TRUE();[.B4];8) 2 The result can be a reference.
=IF(TRUE();
[.B4]+5;8)
7 The result can be a formula.
=IF("x";7;8) Error Condition has to be convertible to Logical.
=IF("1";7;8) Error Condition has to be convertible to Logical.
=IF("";7;8) Error
Condition has to be convertible to Logical; empty string is not
the same as False
=IF(FALSE();7) FALSE Default IfFalse is FALSE
=IF(3) TRUE Default IfTrue is TRUE
=IF(FALSE();7;) 0 Empty parameter is considered 0
=IF(TRUE();;7) 0 Empty parameter is considered 0
=IF(TRUE();4;1/0) 4
If condition is true, ifFalse is not considered even if it would
produce Error.
=IF(FALSE();1/0;5) 5
If condition is false, ifTrue is not considered even if it would
produce Error.
anchor:IF
See also AND, OR
6.15.5 IFERROR
Summary: Return X unless it is an Error, in which case return an alternative value
Syntax: IFERROR( Any X ; Any Alternative )
Returns: Any
Constraints: None.
Semantics: Computes X. If ISERROR(X) is true, return Alternative, else return X. Thus this is
semantically equivalent to IF(ISERROR(X); Alternative; X), except that X is only computed once. If X
or Alternative is a cell reference to an empty cell, it is treated as the empty string "".
anchor:IFERROR
See also IF
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 245 of 442
6.15.6 IFNA
Summary: Return X unless it is an NA, in which case return an alternative value
Syntax: IFNA( Any X ; Any Alternative )
Returns: Any
Constraints: None.
Semantics: Computes X. If ISNA(X) is true, return Alternative, else return X. Thus this is
semantically equivalent to IF(ISNA(X); Alternative; X), except that X is only computed once. If X or
Alternative is a cell reference to an empty cell, it is treated as the empty string "".
anchor:IFNA
See also IF
6.15.7 NOT
Summary: Compute logical NOT
Syntax: NOT( Logical L )
Returns: Logical
Constraints: Shall have 1 parameter
Semantics: Computes the logical NOT. If given TRUE, returns FALSE; if given FALSE, returns
TRUE.
anchor:NOT
Test Cases:
Expression Result Comment
=NOT(FALSE()) True Simple NOT, given FALSE.
=NOT(TRUE()) False Simple NOT, given TRUE.
=NOT(1/0) Error
NOT returns an error if given an
error value
See also AND, IF
Note: NOT returns an Error, if given an Error, so unlike some mathematical definitions this can
return more than two values: True, False, and Error values.
6.15.8 OR
Summary: Compute logical OR of all parameters.
Syntax: OR( { Logical|NumberSequenceList L }
+
)
Returns: Logical
Constraints: Shall have 1 or more parameters
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 246 of 442
Semantics: Computes the logical OR of the parameters. If all parameters are False, it shall return
False; if any are True, it shall returns True. When given one parameter, this has the effect of
converting that one parameter into a Logical value. When given zero parameters, evaluators may
return a Logical value or an Error.
Also in array context a logical OR of all arguments is computed, range or array parameters are not
evaluated as a matrix and no array is returned. This behavior is consistent with functions like SUM.
To compute a logical OR of arrays per element use the + operator in array context.
anchor:OR
Note: Excel 2000, OpenOffice.org 2.0 and Gnumeric 1.4.3 consider OR() with no parameters an
error, Kspread 1.4.2 does not.
Test Cases:
Expression Result Comment
=OR(FALSE();FALSE()) False Simple OR.
=OR(FALSE();TRUE()) True Simple OR.
=OR(TRUE();FALSE()) True Simple OR.
=OR(TRUE();TRUE()) True Simple OR.
=OR(FALSE();NA()) NA Returns an error if given one.
=OR(FALSE();FALSE();TRUE()) True More than two parameters okay.
=OR(TRUE()) True One parameter okay - simply returns it
TBD: Implementations of AND and OR do NOT short-circuit on True and False, because they look
for error conditions and propagate them. For example, on Excel: AND(FALSE(), #NA) is #NA.
Should the "do not short-circuit" rule be REQUIRED? If it is required, should short-circuiting versions
of AND() and OR() be defined, e.g., ANDSC() and ORSC()?
See also AND, IF
6.15.9 TRUE
Summary: Returns constant TRUE
Syntax: TRUE()
Returns: Logical
Constraints: Shall have 0 parameters
Semantics: Returns logical constant TRUE. The result of this function may or may not be equal to 1
when compared using =. It always has the value of 1 if used in a context requiring Number
(because of the automatic conversions), so if ISNUMBER(TRUE()), then it shall have the value 1.
anchor:TRUE
Test Cases:
Expression Result Comment
=TRUE() True Constant.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 247 of 442
=IF(ISNUMBER(TRUE());TRU
E()=1;TRUE())
True
Applications that implement Logical values as 0/1
must map TRUE() to 1
2+TRUE() 3 TRUE converts to 1 in Number context
See also FALSE, IF
6.15.10 XOR
Summary: Compute a logical XOR of all parameters.
Syntax: XOR( { Logical L }
+
)
Returns: Logical
Constraints: Shall have 1 or more parameters.
Semantics: Computes the logical XOR of the parameters such that the result is an addition modulo
2. If an even number of parameters is True it returns False, if an odd number of parameters is True
it returns True. When given one parameter, this has the effect of converting that one parameter into
a Logical value.
anchor:XOR
Note: The multi-argument form is different from an "exclusive disjunction" operation, which would
return True if and only if exactly one argument is True.
Test Cases:
Expression Result Comment
=XOR(FALSE();FALSE()) False Simple XOR.
=XOR(FALSE();TRUE()) True Simple XOR.
=XOR(TRUE();FALSE()) True Simple XOR.
=XOR(TRUE();TRUE()) False
Simple XOR note that this one is different
from OR
=XOR(FALSE();NA()) NA Returns an error if given one.
=XOR(FALSE();FALSE();TRUE()) True More than two parameters okay.
=XOR(FALSE(); TRUE();TRUE()) False
More than two parameters okay, and notice
that this result is different from OR
=XOR(TRUE(); TRUE();TRUE()) True
More than two parameters okay, the result is
((1 XOR 1) XOR 1), thus a parity.
=XOR(TRUE()) True One parameter okay - simply returns it
See also AND, OR
Note: Excel 2003, and OpenOffice.org 2.1 don't have XOR(). Gnumeric 1.4.3 considers AND() with
no parameters an error, Kspread 1.4.2 does not.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 248 of 442
6.16 Mathematical Functions
6.16.1 General
This section describes functions for various mathematical functions, including trigonometric
functions like SIN). Note that the constraint text presumes that a value of type Number is a real
number (no imaginary component). Unless noted otherwise, all angle measurements are in radians.
Note: It's debatable if SUM and AVERAGE etc. should be listed under mathematical functions or as
statistical functions. COUNT could belong here, under statistics, or under information functions. It
doesn't really matter; these divisions are arbitrary, simply to make it easier for users to find them.
6.16.2 ABS
Summary: Return the absolute (nonnegative) value.
Syntax: ABS( Number N )
Returns: Number
Constraints: None
Semantics: If N < 0, returns -N, otherwise returns N.
anchor:ABS
Test Cases:
Expression Result Comment
=ABS(-4) 4 If less than zero, return negation
=ABS(4) 4 Positive values return unchanged.
See also Prefix Operator -
6.16.3 ACOS
Summary: Returns the principal value of the arc cosine of a number. The angle is returned in
radians.
Syntax: ACOS( Number N )
Returns: Number
Constraints: -1.0 <= N <= 1.0.
Semantics: Computes the arc cosine of a number, in radians.
acos ( N )=
|
N+
1
23
N
3
+
13
245
N
5
+
135
2467
N
7
+...
ft "ft"
International Foot, exactly 0.3048 m and
also exactly 12 international inches.
This is not a U.S. survey/statute foot.
"in" "in" in in in
[in_i
]
in "in" International Inch, exactly 2.54 cm.
lightye
ar
[ly] l.y. "ly" *
Light-year, the distance light travels in a
year of 365.25 days. Extant but
undocumented in OOo 2.1.
"m" * "m" m m * m m * m m "m" * Meter
"mi" "mi" mi mi mi
[mi_
i]
mi "mi"
International Mile, exactly 1609.344 m
and exactly 5280 international feet. This
is not a U.S. survey/statute mile (see
smi) nor a nautical mile (see Nmi)
"Nmi" "Nmi" Nmi Nmi
Nmi
[nmi
_i]
Nmi "Nmi"
International nautical mile, exactly 1852
m. Note that this is not the obsolete
U.S. nautical mile nor the Admiralty
mile.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 268 of 442
Unit
grou
p
Excel OOo Corel 1-2-3
Gnu
meri
c
[UNI
FIE
D]
Print
Ecm
a
Proposed
Unit name
Comments
"parse
c"
pc pc
"parsec" or
pc *
Distance from sun to a point having
heliocentric parallax of one second
(used for stellar distance)*
"Pica" "Pica" Pica
Pica
[pca
]
Pica "Pica" Pica (1/72 in.)
[mi_
us]
"statute_mi"
U.S. survey mile, aka U.S. statute mile,
exactly 6336000/3937 m and exactly
5280 U.S. survey/statute feet. This is
not an international mile (see mi).
"yd" "yd" yd yd yd
[yd_
i]
yd "yd"
International yard, exactly 0.9144 m and
exactly 3 international feet. This is not a
U.S. survey/statute yard.
E
n
e
r
g
y
"BTU" "BTU" btu BTU
"BTU
"
BTU
or
btu
"BTU" or
"btu"
BTU. Excel 2003 CONVERT(1, BTU,
kJ) reports 1.055058137867. The
closest BTU in use I can find in
[UNIFIED] is the international table
British thermal unit, which according to
[UNIFIED] is 1.05505585262 kJ. What's
disturbing is that [UNIFIED] has a
default [Btu] equal to [Btu_th], the
thermochemical British thermal unit of
1.054350 kJ.
"c" * "c" c c * c
cal_
th or
cal
calth
or
cal
c "c" *
Thermodynamic calorie, 4.184 J. This is
not a dietary Calorie (kilocalorie). Do not
use for high accuracy, due to many
conflicting definitions of calorie; use
Joule instead. Excel 2003 CONVERT(1,
c, J) reports 4.183991013637; this
far closer to the thermo calorie than any
other calorie in use, but it's somewhat
inaccurate.
"cal" * "cal" cal cal * cal
cal_
IT
calIT cal "cal" *
International Table (IT) calorie, 4.1868
J. This is not a dietary Calorie
(kilocalorie). Do not use for high
accuracy, due to many conflicting
definitions of calorie; use Joule instead.
Excel 2003 CONVERT(1, cal, J)
reports 4.186794846139; this far closer
to the IT calorie than any other calorie in
use, but it's somewhat inaccurate.
"e" "e" e e * e
erg
*
erg e "e" * Erg
"eV" "eV" ev eV * "eV" "eV" "eV"
ev
or
eV
"eV" or ev * Electron volt (eV preferred)
"flb" flb flb flb flb "flb"
Foot-pound (international foot,
avoirdupois pound). OOo doesn't
document flb.
"HPh" "HPh" hh HPh
"HPh
"
Hph
or
hh
"HPh" or hh Horsepower-hour (HPh preferred)
"J" * "J" J J J * J J "J" * Joule
"Wh" "Wh" wh Wh * "Wh"
Wh
or
wh
"Wh" or wh
*
Watt-hour
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 269 of 442
Unit
grou
p
Excel OOo Corel 1-2-3
Gnu
meri
c
[UNI
FIE
D]
Print
Ecm
a
Proposed
Unit name
Comments
F
o
r
c
e
/
W
e
i
g
h
t
dyn" dyn" dy
dyn
*
dyn"
dyn
*
dyn"
dy
or
dyn
"dyn" or "dy"
*
Dyne
"N" * "N" N N * "N" N * N N "N" * Newton
"lbf" lbf lbf "lbf"
[lbf_
av]
lbf lbf "lbf" Pound force (see lbm for pound mass)
"pond" "pond" *
Pond, gravitational force on a mass of
one gram
I
n
f
o
r
m
a
t
i
o
n
bit bit * bit
By byte * Byte = 8 bits
M
a
g
n
e
t
i
c
F
l
u
x
D
e
n
s
i
t
y
"ga" * "ga" ga * "ga" G
G or
Gs
ga "ga" *
Gauss (note: Gs conflicts with Giga-
second)
"T" * "T" T * "T" T * T T "T" * Tesla
M
a
s
s
"g" * "g" g g * g g * g g "g" * Gram
"grain" "grain" 1/7000 international pound mass
(avoirdupois) (U.S. usage).
hweig
ht
uk_cwt or
lcwt
(hweight)
long hundredweight, 112lbm.
"lbm" "lbm" lbm lbm lbm [lb_
av]
lbm "lbm" International pound mass (avoirdupois),
exactly 453.59237 g (see lbf for pound
force)
"stone" [sto
ne_a
v]
"stone" 14 international pound mass
(avoirdupois)
"ton" [sto
n_av
]
"ton" U.S. short ton, 2000 international pound
mass (avoirdupois) (U.S. usage). Note
that there are many other measures
also called ton; in particular, this is not
a metric ton (tonne).
brton [lton
_av]
"uk_ton"
(brton)
brton is in OOo sources, not
mentioned in OOo 2.1 help files. It's
long ton or Imperial ton, 2240 lbm.
"ozm" "ozm" ozm ozm ozm
[oz_
av]
ozm "ozm" Ounce mass (avoirdupois), exactly 1/16
of an international pound mass
(avoirdupois) (see oz for fluid ounce)
pweig
ht
Supposed to be pennyweight, but it's
got the wrong abbreviation
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 270 of 442
Unit
grou
p
Excel OOo Corel 1-2-3
Gnu
meri
c
[UNI
FIE
D]
Print
Ecm
a
Proposed
Unit name
Comments
(pennyweight is dwt which conflicts
with deadweight ton), and OOo 2.1 gets
it wrong anyway. Its
CONVERT_ADD(1;"pweight";"grain")
produces 21.88 but pennyweight should
produce 24. Nobody noticed; clear
evidence no one cares. Dropped per
2007-02-12 email on subcommittee
mailing list
"sg" "sg" sg sg sg sg "sg" Slug
shwei
ght
cwt
Short hundredweight, = 100lbm. Correct
abbreviation is cwt.
t t t * Tonne aka metric ton, 1000 kg.
"u" * "u" u u u
AM
U
u u "u" * U (atomic mass unit)
P
o
w
e
r
"HP" "HP" h HP HP
[HP]
H or
hp
"HP" or h Horsepower. Ecma wrong.
PS PS
Pferdestrke (German horse strength,
close but not identical to HP)
"W" * "W" w W * "W" W * "W"
W
or w
"W" or w * Watt
P
r
e
s
s
u
r
e
"atm" "atm" at
atm
*
"atm" "atm" "atm"
atm
or at
"atm" or at * Atmosphere
bar bar 1E5 Pa
"mmHg"
"mmHg
"
mmH
g *
"mm
Hg"
mmH
g
"mmHg" * mm of Mercury
"Pa" * "Pa" p Pa * "Pa"
Pa
*
Pa
P or
p
"Pa" *
Pascal; Pa is the standard abbreviation.
Note Ecma appears grossly
incompatible.
"psi"
[psi]
psi "psi"
Pounds per square inch, using
avoirdupois pounds and international
inches.
"Torr" "Torr"
Torr, exactly 101325/760 Pa (this is
close but not equal to mmHg)
S
p
e
e
d
admkn
admkn
Admiralty knot, exactly 6080
international feet/hour.
kn
[kn_
i]
"kn"
Knot, exactly one Nautical mile per hour
or exactly 1852/3600 m/s. Note that this
is not an Admiralty knot (admkn).
m/h
m/h or
m/hr
Meters per hour
m/s
m/s or
m/sec *
Meters per second
mph mph Miles per hour (international miles)
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 271 of 442
Unit
grou
p
Excel OOo Corel 1-2-3
Gnu
meri
c
[UNI
FIE
D]
Print
Ecm
a
Proposed
Unit name
Comments
T
e
m
p
e
r
a
t
u
r
e
"C" "C" cel C "C"
Cel
*
"C"
C or
cel
"C" or cel degrees Celsius
"F" "F" fah F "F"
[deg
F]
"F"
F or
fah
"F" or fah degrees Fahrenheit
"K" * "K" kel K * "K" "K" * "K"
K or
kel
"K" or kel * Kelvin
Rank ran "Rank" Rankine
Reau Reau Raumur, [C] = [R] 5/4.
T
i
m
e
"day" "day" day day day d d day "day" or d Day (exactly 24 hours)
"hr" "hr" hr hr hr h h hr "hr"
Hour (exactly 60 minutes); h conflicts
with old horsepower.
"mn" "mn" mn mn mn min min mn "mn" or min Minute (exactly 60 seconds)
sec sec sec
sec
*
sec s * s sec "sec" or s *
Second (s is the official abbreviation of
this SI base unit, while sec is its
traditional abbreviation in the
CONVERT function) *
"yr" "yr" yr yr yr
a
or
a_j
yr "yr"
Year (exactly 365.25 days, for purposes
of this function)
V
o
l
u
m
e
ang3 "ang3" or
"ang^3"
Cubic angstrom
barrel [bbl
_us]
GRT
("regton")
Gross registered ton (register ton), 100
cubic (international) feet.
"tbs" "tbs" tbs tbs tbs
[tbs
_us]
tbs "tbs"
Tablespoon (U.S. customary, traditional)
0.5 U.S. fluid ounce.
"tsp" "tsp" tsp tsp tsp
[tsp
_us]
tsp "tsp"
Teaspoon (U.S. customary, traditional
meaning), 1/6 fluid ounce, U.S.
customary
"tspm" Modern teaspoon, 5mL
"uk_pt"
[pt_
br]
uk_p
t
"uk_pt" U.K. pint
yd3
[cyd
_i]
"yd3" or
"yd^3"
Cubic international yard
Schoo
ner,
Middy
,
Glass
Dropped per 2007-02-12 message
Note that existing spreadsheet implementations already have some naming conventions, namely, in
English measures the U.S. Customary is the default, and Imperial measures (where different) begin
with uk_ (as in uk_pt).
The following are more specific rationales about these units:
Area
Some of the area measures listed here are improbable, but it was felt to be important to consistently
support the square of nearly all distance measures.
The unitname acre is not required to be defined by this function, since the term has different
official meanings in different locales. Instead, two different acre-based units are given. The official
U.S. definition of acre as presented by NIST SP 811 (see B.6) uses U.S. survey/standard feet,
which are not the same as the international feet typically used in the U.S. In the Imperial system,
and in many programs such as Google's unit calculator on 2007-02-08, an acre is defined using
international feet. The names given here follow the conventions already established by pint (e.g.,
us_pt vs. uk_pt), because they are valid for acre; in the U.S. an acre is the acre defined by survey
feet (per NIST), while elsewhere an acre is defined using the more typical international feet.
The unit are (100 m
2
) is abbreviated here as ar instead of the official standard a. This is the
same abbreviation used by [UNIFIED]. One reason is that a is also strongly advocated as an
abbrevation for year. Because there are conflicting definitions for a, neither is assigned the
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 273 of 442
symbol a until it is resolved. OpenOffice.org 2.1 already uses ar as the abbreviation for are, so
there is precedence in a widely-used spreadsheet implementation. Note that the common unit ha
(hectare) is separately defined, without permitting other prefixes on it; this supports the common
case (so users can use ha directly). A side-effect is that if a is someday defined as year, then
ha cannot be used as 100 years; since users are more likely to talk about centuries instead of
ha meaning 100 years, this is not likely to be a real problem.
The Morgen is included because OpenOffice.org 2.1 includes it (a Morgen is 2500 m
2
).
Distance
The official abbreviation of anstrom is , but this is difficult to type and see on many systems, so
ang is used instead. This is consistent with historical use of CONVERT, though not with [UNIFIED]
which uses Ao instead.
The U.S. Survey mile must not be us_mi, because normally miles in the U.S. are international
miles. It is only in certain land surveys that survey miles (aka statute miles) are used.
The definition of parsec is from CRC Handbook for Chemistry and Physics, 63
rd
ed. The IAU
defines the value of parsec as 30.857 Pm (http://www.iau.org/Units.234.0.html). OpenOffice.org 2.1
uses 1 parsec = 30856778570831.3 km. The standard abbreviation for parsec was not in
OpenOffice.org 2.1, so that was added. One complication is that the standard abbreviation pc
overrides the pico-calorie, but that is a very improbable measure so this is accepted.
A widely-used distance measure in astronomy is the astronomical unit (AU), the distance from Earth
to the Sun. This is not currently included, due to questions about its value and its standard symbol.
There seems to be some disagreement over its exact value. (E.G.., Wikipedia claims "The currently
accepted value of the AU is 149 597 870 691 30 metres"; Wikipedia isn't authoritative, but it's a
good hint that there is disagreement.) [UNITED] gives 149597.870 Mm as its value. We can give its
physical definition, but that implies that as the value's measure improves, applications might need to
change the conversion factor (!). Another problem is that there are many different standard symbols
used for it: ua, au, and AU. BIPM uses "ua" as its abbreviation, but the "a" is also "year" AND
"are", so "ua" would interfere with "micro-year" and "micro-are (so many conflicts are not a good
sign). The IAU recommends "au", and normally they'd be authoritative in such matters, but "au" is a
poor unit name; it conflicts with atto-u. ISO 31-1 and [UNITED] use AU, which seems the best of
these three choices, though the fact that there's conflict still gives room for pause. We really want
unique, internationally agreed-upon unit names that use solely case-sensitive ASCII characters;
here we don't have that.
A light-year is the distance light travels in a year; several different definitions of year have been
used, but the IAU recommends using a year of 365.25 days (http://www.iau.org/Units.234.0.html),
so it is defined that way here.
Energy
The unit HPh, not Hph, is used for horsepower-hour, because that is what current
implementations accept.
There are a disturbingly large number of different definitions for the calorie (e.g., see [UNIFIED]).
There are small calories and large calories, and a vast number of versions of each. Because of this
widespread confusion, calories should be avoided where accurate measures are desired. If
accuracy is desired, use Joule instead. The International Steam Table Calorie (1956) is 1.163 mW h
= 4.1868 J exactly, adopted by the Fifth International Conference on Properties of Steam (London,
July 1956). The Thermochemical/Thermodynamic calorie is 4.184 J exactly. Excel 2003 gets slightly
wrong results; in Excel, 1 c = 4.18399101363672 J, and 1 cal = 4.18679484613929 J.
A similar argument holds for BTU as for calorie.
Force/ Weight
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 274 of 442
The term force is used as the primary term, not weight, because weight is simply a special case
of force (namely, the force due to gravity).
The English unit pound (traditionally abbreviated lb) can be either a measure of mass or a
measure of force. The abbreviations lbf and lbm distinguish these different uses of pound.
OpenOffice.org 2.1 grouped units somewhat differently; it had a weight group, and no mass
group, and most of its weight measures (such as grams) were really measures of mass. This
specification has two distinct groups, force and mass, because these physically distinct. This results
in lbf and lbm for pound-force and pound-mass, because the term pound is often used for
either measure.
The standard acceleration of gravity in free fall is 9.80665 m/s
2
.
Information
The information units bit and byte were added, since they are widely used, and conversions are
often needed that are nontrivial for nonexperts (e.g., between decimal and binary versions). The
octet o abbreviation was not added; the octet is a far less common term, and there was hesitation
to use up a single-letter abbreviation for such an unusual case. Support for binary prefixes was
added because as systems become more capable, the errors from misusing binary prefixes become
more serious.
The official abbreviations for bit and byte are b and B respectively. But b is also the official
abbreviation for barn, and B is the official abbreviation for Bel (as in deciBel). [UNIFIED]
defines B as Bel, b for barn, bit for bit, and By for byte. Ordinary users might consider it
confusing that bit is not abbreviated, but byte is, which is a good reason to not abbreviate either
(and thus we differ from [UNIFIED] here). More importantly, adding a symbol such as b or B that
has a known conflict with other standard symbols was considered unwise.
The solution used here is to simply use their full names as the symbol. This is extremely clear to all
readers, and is very unlikely to conflict with any agreement in the future.
A probable future addition would be information rates (bit/s and byte/s). Note that baud is not the
same as bit/s or byte/s, but instead measures signalling rates.
Magnetic Flux Density
Both the Tesla and Gauss are included because they are widely supported (e.g., in Excel and
OpenOffice.org 2.1); the Tesla is the SI derived unit, and is thus preferred internationally.
Mass
In SI, the kilogram is actually the base unit of mass. This specification does not conflict with SI on
this point; instead, it simply states that for purposes of creating unit names the base unit is the
gram, as required by SI.
There are other systems besides Avoirdupois, but they have only a specialized use (e.g., Troy is
typically only used for precious metals, and Apothecaries' has been essentially displayed by SI).
Thus only avoirdupois is required to be supported by this function because it is by far the most
common case. There is no required support for Troy, Apothecaries', or the historical Tower measures
by CONVERT.
The ton has a very large number of different definitions, but in the U.S. its common meaning is
2000 pounds (aka the short ton), and there is already precedence for this meaning in
OpenOffice.org 2.1, so this particular meaning was chosen. A similar argument holds for grain.
OpenOffice.org 2.1 included the mass unit symbols hweight (hundredweight) and shweight (short
hundredweight). These are not their standard unit symbols, which are lcwt (long hundredweight, 112
lbm) and ctw (hundredweight, 100 lbm), per
http://scienceworld.wolfram.com/physics/AvoirdupoisSystemofUnits.html. The old OOo 2.1 symbols
were poorly documented, so it is unlikely that the original symbols were actually used (and thus
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 275 of 442
there's no need to include the old ones for interoperability). These measures are used, but not
extensively, even in their putative field (e.g., a U.S. Navy glossary of measures included various
tons but not these measures). So there was hestitation in adding them as required units. Note that
cwt would interfere with creating a prefixed unit symbol wt (cwt couldn't be centi-wt), but we
don't know of any wts. For the long hundredweight, another possible symbol would be uk_cwt,
because the hundredweight in the Imperial system is 112lbm while in the U.S. customary system it
is 100lbm.
The symbol dwt is not used, because this is a common abbreviation for pennyweight.
For mass unit symbols with names based on ton, see the Ton section (below).
Mass and energy can theoretically be converted to each other, per E=mc
2
, but they are considered
separate units by CONVERT to help users detect unintentional errors.
Power
Power and energy are not the same thing; power is energy/time.
Excel 2003 requires HP or h for horsepower; it does not accept hp or H. In contrast, the Excel
specification Ecma-376 (December 2006) requires hp or H, and implicitly forbids HP or h.
Since the Ecma specification is supposed to document what Excel does, we interpret this as an
error in Ecma-376, and the table above includes Excel's actual behavior not Ecma-376's
specification.
The use of h to represent horsepower is deprecated (we recommend using HP instead), so that
in a future version of this specification h could mean hour. The symbol h is the official
abbreviation for hour, but this cannot be easily supported as long as it has another conflicting
meaning.
PS is close to, but not the same as the horsepower of HP. It stands for Pferdestrke (German
horse strength), and is still a common measure for cars in Europe. It implies measurement at the
wheels, not at the engine, but that distinction is outside the scope of this document.
Pressure
Excel 2003 does not accept P for Pascal (it does accept Pa or p), while Ecma requires P or
p (and not Pa). Pa is the standard abbreviation for Pascal, and lowercase p creates ambiguity
problems (see below).
The Torr and mmHg are very similar, but not identical. The Torr is 101325/760 Pa; see the U.K.'s
National Physical Laboratory site at http://www.npl.co.uk/pressure/punits.html for more information.
Speed
This group is labelled speed, not velocity, because velocity implies a direction; the scalar absolute
value (magnitude) of velocity is speed.
Temperature
Unlike most conversions, many of the temperature unit conversions require an addition or
subtraction as well as a multiplication. However, they are still unit conversions, and have historically
been done by CONVERT, so they are included.
Rankine is R = (C + 273.15) 1.8
Kelvin is not measured in degrees but is simply a unit of measure, while Celsius and Fahrenheit
are measured in degrees, per the 13th General Conference on Weights and Measures (CGPM) in
19671968. Thus the omission of the term degrees in the cell describing Kelvin is intentional.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 276 of 442
Reau is for Raumur, a historical temperature scale used in Europe before Celcius and supported
by OpenOffice.org 2.1. See http://en.wikipedia.org/wiki/R%C3%A9aumur_scale. In this scale, 0 is
freezing, and 80 is boiling, so [C] = [R] 5/4.
Time
The Earth does not orbit the Sun in exactly 365.25 days, but for purposes of calculation it is typically
assumed to do so.
The abbreviation for year is yr; some documents advocate using a, but a is also the
abbreviation for are (and the hectare is used widely). All spreadsheets currently use yr, which is
not ambiguous, so this is retained. If a is added, and prefixes are also allowed, a conflict then
exists between Pa (Pascal) and Pa (Petayears). This is not too bad; by the rule of preferring
unprefixed unit symbols, this would be resolved as a Pascal. But given the conflict, no change has
yet been made.
Spreadsheets widely agree on non-standard symbols for time. The international system of units
includes the symbols s (second), min (minute), and d (day) these were added as alternative
unit symbols for standards compliance. In particular, note that s is a base unit in SI, and it was
particularly bizarre that s was not supported as a unit.
It is nontrivial to add the standard symbol for hour (h), because was originally used for
horsepower. This specification deprecates h, to prepare for use of h as hour.
Volume
Some of the volume measures listed here are improbable, but it was felt to be important to
consistently support the cube of nearly all distance measures.
Note that volumes are not limited to liquid measures, but also include spatial volumes. Excel
documentation refers to liquid measures, but this is excessively limiting.
There are a large number of measures all called barrel; the one labelled barrel is widely used for
measuring oil, and is the one used by OpenOffice.org 2.1. Similarly, there are many bushels, the
one used by OpenOffice.org 2.1 was chosen (since Excel does not implement one).
The definition of teaspoon and tablespoon in this function are not the same as those used today
in many countries. This is because the definitions have changed in some countries since these
measures were originally defined in CONVERT. The definitions used in CONVERT are their original
meanings in spreadsheets, which matched the U.S. standards when they were added. These have
not been changed in CONVERT, because changing the meaning in spreadsheets of tsp and tbs
now would cause a subtle change in existing spreadsheets' values. This could be dangerous since
these measures are sometimes used for medicines. In particular:
Teaspoon: Teaspoon tsp continues to have its U.S. customary, traditional meaning of 1/6 fluid
ounce, in U.S. customary measure. Note that this is not the 1/8 Imperial fl. oz. per Imperial
units. More importantly, it is not 5 mL, a common meaning today due to a change in standard
definitions. For example, U.S. federal law, 21CFR101.9(b)(5)(viii), now defines a teaspoon as
5mL for purposes of nutritional labels, as is true with many other countries such as Canada,
New Zealand, and the U.K. Since there is a consensus redefinition of teaspoon, but there was
a need to not subtly break existing documents, the tspm was created as the metric/modern
teaspoon of 5mL.
Tablespoon: Historically the traditional Imperial tablespoon could vary from 1/2 to 5/8 Imperial fl.
oz. (14.2 mL to 17.8 mL). In many countries, the tablespoon is now 15mL; e.g., U.S. federal law,
21CFR101.9(b)(5)(viii), defines a tablespoon as 5ml for purposes of nutritional labels, as is true
with many other countries such as Canada, New Zealand, and the U.K. However, in Australia,
one tablespoon is 20ml. Since there is some disagreement on a redefinition of tablespoon, no
modern/metric tablespoon measurement has been proposed. If there is consensus in the future,
tbsm would be the logical choice.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 277 of 442
A common abbreviation of cubic centimeters is cc, but this conflicts with centi-calories (cc). This is
not limiting; for cubic centimeters, simply use cm3 or cm^3. Conversions between different
groups is prohibited so accidental use of cc would normally be detected by the CONVERT
function.
L was added as a synonym for liter because the National Institute of Standards and Technology
(NIST) Special Publication (SP) 811, Guide for the Use of the International System of Units (SI),
1995, at http://physics.nist.gov/Pubs/SP811/sec06.html#6.1.2 recommends the use of L not l for
liters. The lowercase l is too easily confused with the digit 1. The abbreviation lt is nonstandard,
and is included for compatibility with older documents.
OOo 2.1 volume measures Schooner and Middy were dropped. These are Australian liquid
measures. However, these sizes vary. Australia's NSW Office of Fair Trading Trade measurement
and the sale of health products, food and alcohol document states that The colloquial terms, such
as seven, middy and schooner do not indicate any particular size of glass. Traders should be
aware that any advertising using such terms should be qualified by the indication of the actual size
of the glass being used on the premises eg middy (280 mL) middy (285 mL) or schooner (400
mL) schooner (425 mL). This document was retrieved 2007-02-11 from
http://www.fairtrading.nsw.gov.au/business/runningabusiness/trademeasurementsaleofhealthfoodalc
ohol.html
OOo 2.1's volume measure Glass was dropped. OpenOffice.org computes 1 Glass as 0.2 liters,
i.e., =CONVERT_ADD(1;"Glass";"l") is 0.2. There was no evidence this was an important unit to
support for interoperability.
For volumes with names based on ton, see the Ton section (next).
Ton
The word ton has a variety of meanings, some as mass and others as volume. The main ones in
use, and thus included here, were determined to be:
"ton", U.S. customary short ton, mass, 2000 pounds (avoirdupois) (this is the U.S. customary
ton, aka short ton). Uses the usual CONVERT convention "non-prefix is U.S. conventional".
[UNIFIED] uses the nasty symbol "[ston_av]".
"uk_ton" - Imperial ton, mass, 2240 pounds (avoirdupois). Uses the usual CONVERT naming
convention, with "uk_" prefix meaning "Imperial". [UNIFIED] uses the symbol "[lton_av]". The
"long ton", "deadweight ton", and "weight ton" are all also 2240-pound tons, just like the Imperial
ton (see http://usmilitary.about.com/od/glossarytermsm/g/m3895.htm). The suggestion is to just
use "uk_ton", continuing the tradition that the "uk_" prefix means "Imperial". The is no clear
need for additional symbols for the same measure, so only this symbol was defined. (Note that
dwt is the standard symbol for a pennyweight, a very different measure). OOo 2.1 used the
term brton, but this was naming was inconsistent with uk_pt. Instead, uk_ is used as the
prefix to mean Imperial measure, and thus uk_ton is used.
"t" - tonne / metric ton, mass, 1000 kg. "t" is the widely-used symbol; [UNIFIED] uses "t" also.
That's a really short unit name, which can be a problem, but it's the normal abbreviation and the
fact that [UNIFIED] is willing to make it "t" suggests that it's okay in practice.
"GRT", gross registered ton, volume, 100 cubic (international) feet. Not mentioned in [UNIFIED].
"MTON" - Measurement ton aka freight ton, volume, 40 cubic feet. It's a unit of volume used
for describing ship capacities (tonnage) or cargo. Not mentioned in [UNIFIED] (note that if we
use this symbol, we'll have trouble adding a prefix-permitting "TON"!). One nasty problem is that
its common abbreviations are "M/T", "MT", or "MTON". All of those abbreviations are easily
confused with the metric ton (though at least metric ton is mass, while measurement ton is
volume, so CONVERT will notice the problem). I'd prefer using "MTON", so that we don't cause
troubles with mega-T (in general, short symbols can cause more grief in CONVERT, because
we want all unit names to be unique).
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 278 of 442
Prefixes are forbidden on all but "t". [UNIFIED] is willing to give "t" decimal prefixes, and tonne is
simply 1000kg, so there's some logic in using prefixes for tonne. Note that the ft (femtoton) won't
be accepted, because ft is interpreted as feet instead. This isn't considered a real problem,
because in that mass range people use grams instead.
Miscellaneous rationale:
The third parameter is named Into, not To, because To is a reserved word in some
programming languages. This should simplify some implementations.
The CONVERT function is specifically designed so that a unit name means exactly one thing,
instead of attempting to determine the meaning from context, which speeds calculation and reduces
the chance of undetected error. This means that future versions will need to beware of defining new
unit names (especially short ones) or prefixes, and examine standard abbreviations before doing so.
E.G., if a unit name d were added, and cd was interpreted as centi-d, that might later be silently
reinterpreted as candela (cd) if candela were added even later.
Early versions of this specification recommended permitting prefixes in front of any unit, but this was
instead changed to a should not:
Current applications generally do not permit prefixes in front of arbitrary units, and while there
were no strong objections, there was no strong rationale for permitting them either.
This would cause interoperability problems, because if one application accepted kmi
(kilomiles) and another didn't, users could easily create spreadsheets that failed to exchange
correctly between conforming implementations.
This could cause significant growth problems, because many obsolete and specialized units
can easily interfere this way. For example, [UNIFIED] uses [mi_i] for miles and [nmi_i] for
nautical miles. If the brackets and _i were dropped, you could have mi and nmi; these do no
conflict if neither accepts prefixes, but otherwise nmi looks like nano-miles. There are many
hidden traps in trying to add new units if all units permitted prefixes.
Evaluators claiming to support this function shall permit the following unit decimal prefixes to be
prepended to any unit symbol marked with * in the unit table cell above. Adding a unit prefix
indicates multiplication of the (scalar) unit by the given prefix value; for example km indicates
kilometres, and km2 or km^2 indicate square kilometres.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 279 of 442
Table 27 - Decimal Prefixes for use in CONVERT
Unit Prefix Description Prefix Value
"Y" yotta 1E+24
"Z" zetta 1E+21
"E" exa 1E+18
"P" peta 1E+15
"T" tera 1E+12
"G" giga 1E+09
"M" mega 1E+06
"k" kilo 1E+03
"h" hecto 1E+02
da or "e"
deka (note: e is
not a standard SI
prefix)
1E+01
"d" deci 1E-01
"c" centi 1E-02
"m" milli 1E-03
"u"
micro (note: this
is u, not the
standard SI )
1E-06
"n" nano 1E-09
"p" pico 1E-12
"f" femto 1E-15
"a" atto 1E-18
"z" zepto 1E-21
"y" yocto 1E-24
The prefix e for 10
1
is nonstandard and included for backward compatibility with legacy
applications and documents.
Rationale: These are the standard SI unit prefixes, with two exceptions: micro and deka. Officially
the prefix for micro is , but on many systems this is difficult to type and/or see, and it is not even
available in some systems, so the traditional (and universally-used) substitution of u is used here
instead ([UNIFIED] does this too). Older spreadsheet implementations only permitted the use of the
nonstandard prefix "e" for deka (10
1
), even though da is easily supported by common character
sets. This specification adds support for the standard SI prefix da to fully support SI; for
interoperability with legacy applications and documents it also permits the use of the legacy e
prefix.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 280 of 442
Excel 2003, Lotus 1-2-3, and Corel Word Perfect (Quattro Pro) 12 do not support the standard SI
prefixes Z, Y, z, and y. OpenOffice.org 2.1 and Gnumeric 1.4 do support the standard SI prefixes Z,
Y, z, and y. They have been included as required prefixes because they are standard SI prefixes,
are useful, and are already supported by some implementations. In short, we try to support standard
SI prefixes as much as possible within a narrow character set.
No spreadsheet applications currently implement the binary prefixes, but since they are a relatively
recent standard this is not surprising.
Only some unit symbols are required to support prefixes, and other unit symbols should not support
the prefixes. So "km" (kilometers) must be supported, but "kmi" (kilomiles) should not be. Reason 1:
If app A accepts a "kmi", but app B doesn't, we have an interoperability problem. Reason 2: If we
accept prefixes everywhere, there's a GREATLY increased probability of future problems with a unit
suddenly changing its meaning (because some prefixed form in an earlier version suddenly conflicts
with a new unit name). E.G., if in the future we added a new unit called the "kmi", it would conflict
with a current "kilomile". It's best to avoid this. Reason 3: Existing spreadsheet applications enforce
this restriction (such as Excel and Gnumeric), as do other systems such as [UNIFIED]. Note that
this specification identifies with specificity which units must support the prefixes; a specification
must be clear to be useful.
Informally, sometimes K is used for k or ki (see below). But this is not technically correct; by
international standards, only k is 1000 and only ki is 1024. There seemed to be no strong need
to support these informal prefixes (including for interoperability), so CONVERT is not guaranteed to
support them.
Note: Implementors must beware of the interaction of powers and prefixes. For example, 3 km
2
is
equal to 3,000,000 m
2
and not to 3000 m
2
or 9,000,000 m
2
.
The unit names marked with in the unit symbol table above (see the Information group) shall also
support the following binary prefixes per IEC 60027-2:
Table 28 - Binary prefixes for use in CONVERT
Binary Unit
Prefix
Description Prefix Value Derived from
"Yi" yobi 2^80 = 1 208 925 819 614 629 174 706 176 yotta
"Zi" zebi 2^70 = 1 180 591 620 717 411 303 424 zetta
"Ei" exbi 2^60 = 1 152 921 504 606 846 976 exa
"Pi" pebi 2^50 = 1 125 899 906 842 624 peta
"Ti" tebi 2^40 = 1 099 511 627 776 tera
"Gi" gibi 2^30 = 1 073 741 824 giga
"Mi" mebi 2^20 = 1 048 576 mega
"ki" kibi 2^10 = 1024 kilo
Note: These binary prefixes are per IEC 60027-2/IEEE 1541. The second edition of 60027-2 didn't
include Zi or Yi, but the third edition added these obvious extensions. The expectation is that
these binary prefixes would only be used for information units such as bit and byte, but these
prefixes are very useful in such cases. Binary prefixes are important; the confusion between binary
prefixes and decimal prefixes has led to litigation in multiple court cases. Legally, SI prefixes are
only base 10. When computers were less capable, the difference between binary prefixes and
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 281 of 442
decimal prefixes was not significant, but the difference has become greater as computers have
become more capable. For example, 100 TB is approximately the same as 90.9 TiB. The binary
prefix value is shown here without being superscripted, because superscripting inside a table might
result in this key term being too small to be easily read.
In the case where there is a naming conflict (a unit name with a prefix is the same as an unprefixed
name), the unprefixed name shall take precedence.
Rationale: Without this rule, some naming conflicts would occur, particularly hh (hoursepower-hour
and hectohorsepower). If p is accepted for Pascal, then we would also have "hp" (horsepower and
hectoPascals). Also, pc is parsec or pico-calories. This is easily implemented, e.g., compare the
unit against a unit name first, and only when that fails should a prefix be looked for. Hectopascals
are in use, but since their standard abbreviation is hPa, this causes no real problem.
Note: The format is specifically designed so that this probable extension would be easy to do.
Evaluators may implement this conversion by first converting to some SI unit (e.g., meter and
kilogram), and then convert again to the final unit.
anchor:CONVERT
Rationale: This permission enables simple implementations. Implementations which take this
approach will in some cases have a very small roundoff error when converting between pairs of non-
SI-based units. This first A then B might be implemented by a precalculated table, but if it's not
exact the result is the same. By being explicit about SI units, we ensure that if there's a trade-off at
all, the best accuracy always goes to the SI units (which is what the most accurate measurements
are typically measured with anyway). This is merely a permission; implementations may do better.
Test Cases:
Expression Result Comment
=CONVERT(1; "ft";"in") 12
1 foot is 12 inches. Conversion between units might
involve an intermediate SI unit in some
implementations, and such round-off error is considered
acceptable.
=CONVERT(1; "in";"cm") 2.54
1 inch is 2.54 cm. The result is exact, because this
needs to be represented as accurately as the underlying
numerical model permits
=CONVERT(5; "m";"mm") 5000 5 meters is 5000 millimeters
=CONVERT(100; "C";"F") 212
212 degrees F is 100 degrees C. Note that this is not
simply a multiplicative relationship. Since internally this
is (100/5*9+32), where 100/5 is exactly 20, this result
needs to be exact even on floating-point
implementations
=CONVERT(2; "Ym";"Zm") 100 Must support Y and Z prefixes.
=CONVERT(20; "F";"m") Error Different groups produce an error.
=CONVERT(1000;"qt";"l") 946.5588641 Quart is U.S. customary, liquid measure
=CONVERT(1000;"tbs";"l") 14.78998225
Tablespoon uses U.S. customary historic definition
note that there are many other definitions
=CONVERT(1000;"tsp";"l") 4.929994084 Teaspoon uses U.S. customary historic definition note
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 282 of 442
that there are many other definitions
=CONVERT(1;"das";"sec") 10
Does it support both s and sec for second? Does it
support da as the SI standard deka prefix?
=CONVERT(1;"ar";"m^2") 100 A hectare (ar) is 100 square meters.
=CONVERT(1;"cal";"J") 4.18680.0001 "cal" is an International Table (IT) calorie, 4.1868 J.
=CONVERT(1;"lbf";"N")
4.4482220.0000
01
Converting pound-force to Newtons
=CONVERT(1;"HP";"W") 745.7010.001 Horsepower to Watts
=CONVERT(1;"Mibyte";"bit"
)
8388608 Converts bytes to bits, and tests binary prefixes
=CONVERT(1;"T";"ga") 10000 Tesla to Gauss
=CONVERT(1;"lbm";"g")
453.592370.000
01
International pound mass (avoirdupois) to grams. (This
is actually exact.)
=CONVERT(1;"uk_ton";"lbm
")
22400.001
Imperial ton, aka long ton, "deadweight ton", or "weight
ton", is 2240 lbm.
=CONVERT(1;"psi";"Pa") 6894.760.01 Pounds per square inch to Pascals.
=CONVERT(60;"mph";"km/
h")
96.560640.0000
1
Miles per hour to kilometers per hour.
=CONVERT(1;"day";"s") 864000.001
Day to seconds. Note: This test uses the international
standard abbreviation for second (s), not the
abbreviation traditionally used in spreadsheets (sec);
both s and sec must be supported.
=CONVERT(1;"qt";"L")
0.9463529460.0
001
Quart (U.S. customary liquid measure) to liter. This is
0.946352946 liters,
See also EUROCONVERT
Rationale: A simple implementation of this function might convert any value into some common
value (e.g., all lengths into meters) and then reconvert it into the final value. A more accurate
implementation would have exact conversions between any pair, or at least try to avoid converting
between SI and English (including U.S. and Imperial) systems unnecessarily which often induces
rounding errors. The test cases are written so that simple implementations that use an SI unit as
their common value will be acceptable.
This table does not test all of the unit symbols or all prefixes, though a compliant application would
implement them as specified. Doing so would require a much longer table, one that would probably
not significantly improve the clarity of this specification. However, all of the unit groups, as well as
some of the most likely errors, are represented.
6.16.19 COS
Summary: Return the cosine of an angle specified in radians.
Syntax: COS( Number N )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 283 of 442
Returns: Number
Constraints: None
Semantics: Computes the cosine of an angle specified in radians.
cos N=1
N
2
2!
+
N
4
4!
N
6
6!
+...
anchor:COS
Test Cases:
Expression Result Comment
COS(0) 1
COS(0) is 1 require this result to be exact, since documents
may depend on it.
=COS(PI()/4)*2/SQR
T(2)
1 cosine of PI()/4 radians is SQRT(2)/2.
=COS(PI()/2) 0
cosine of PI()/2 radians is 0; the test here gives a little "wiggle
room" for computational inaccuracies.
See also ACOS, RADIANS, DEGREES
6.16.20 COSH
Summary: Return the hyperbolic cosine of the given hyperbolic angle
Syntax: COSH( Number N )
Returns: Number
Constraints: None
Semantics: Computes the hyperbolic cosine of a hyperbolic angle. The hyperbolic cosine is an
analog of the ordinary (circular) cosine. The points (cosh t, sinh t) define the right half of the
equilateral hyperbola, just as the points (cos t, sin t) define the points of a circle.
cosh( N )=
e
N
+e
N
2
anchor:COSH
Test Cases:
Expression Result Comment
=COSH(0) 1 Cosh(0) is 0
=COSH(1)
1.54308063
48
=COSH(EXP(1))
7.61012513
866
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 284 of 442
See also ACOSH, SINH, TANH
6.16.21 COT
Summary: Return the cotangent of an angle specified in radians
Syntax: COT( Number N )
Returns: Number
Constraints: None
Semantics: Computes the cotangent of an angle specified in radians.
COT(x) = 1 / TAN(x)
anchor:COT
Test Cases:
Expression Result Comment
=COT(PI()/4.0) 1 cotangent of PI()/4.0 radians.
=COT(PI()/2.0) 0
cotangent of PI()/2 radians. Not the same as
TAN.
=COT(0) Error COT(0) = 1/TAN(0) = 1/0, a division by zero
See also ACOT, TAN, RADIANS, DEGREES, SIN, COS
6.16.22 COTH
Summary: Return the hyperbolic cotangent of the given hyperbolic angle
Syntax: COTH( Number N )
Returns: Number
Constraints: N<>0
Semantics: Computes the hyperbolic cotangent of a hyperbolic angle. The hyperbolic cotangent is
an analog of the ordinary (circular) cotangent.
coth( N )=
1
tanh( N )
=
cosh( N )
sinh( N)
=
e
N
+e
N
e
N
e
N
anchor:COTH
Test Cases:
Expression Result Comment
=COTH(1)
1.31303528
5
=COTH(EXP(1))
1.00874693
0
Z0
e
t
2
dt
With two arguments, returns
ERF (Z0 ; Z1)=
2
.
(n)
Z0
Z1
e
t
2
dt
anchor:ERF
Test Cases:
Expression Result Comment
=ERF(0.5) 0.520500
=ERF(0.1) 0.112463
=ERF(0.1; 0.5) 0.408037
=ERF(0.1)-ERF(0.5) -0.408037 ERF(z0,z1) equals ERF(z1) - ERF(z0)
See also ERFC
6.16.28 ERFC
Summary: Calculates the complementary error function.
Syntax: ERFC( Number z )
Returns: Number
Constraints: None
Semantics: returns the complementary error function of z: ERFC(z) = 1 ERF(z)
anchor:ERFC
Test Cases:
Expression Result Comment
=ERFC(0.1)-(1-
ERF(0.1))
0 ERFC(z) = 1 ERF(z)
=ERFC(3) 2.2090e-5
ERFC is typically more accurate than 1-ERF for
larger values of z.
See also ERF
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 288 of 442
6.16.29 EUROCONVERT
Summary: Converts a Number, representing a value in one European currency, to an equivalent
value in another European currency, according to the fixed conversion rates defined by the Council
of the European Union.
Syntax: EUROCONVERT( Number N ; Text From ; Text To [ ; Logical FullPrecision = FALSE() [ ;
Integer TriangulationPrecision ] ] )
Returns: Currency
Constraints: From and To shall be known to the evaluator. TriangulationPrecision shall be >= 3, if
not omitted.
If an evaluator does not support the parameters FullPrecision and TriangulationPrecision,
FullPrecision should be assumed to be false.
Note: Gnumeric 1.4 supports only 3 parameters and calculates as if FullPrecision was True.
Gnumeric developers agreed to change implementation.
Semantics: Returns the given money value of a conversion from From currency into To currency.
Both From and To shall be the official ISO 4217 abbreviation for the given currency; note that these
are in upper case, but the function accepts lower case or mixed case as well. If From and To are
equal currencies, the value N is returned, no precision or triangualation is applied.
The function shall use the rates of exchange as set by the European Commission, as follows:
Table 29 - EUROCONVERT
From To Rate Currency Decimals
"EUR" "ATS" 13.7603 Austrian Schilling 2
"EUR" "BEF" 40.3399 Belgian Franc 0
"EUR" "DEM" 1.95583 German Mark 2
"EUR" "ESP" 166.386 Spanish Peseta 0
"EUR" "FIM" 5.94573 Finnish Markka 2
"EUR" "FRF" 6.55957 French Franc 2
"EUR" "IEP" 0.787564 Irish Pound 2
"EUR" "ITL" 1936.27 Italian Lira 0
"EUR" "LUF" 40.3399 Luxembourg Franc 0
"EUR" "NLG" 2.20371 Dutch Guilder 2
"EUR" "PTE" 200.482 Portuguese Escudo 2
"EUR" "GRD" 340.750 Greek Drachma 2
"EUR" "SIT" 239.640 Slovenian Tolar 2
EUR MTL 0.429300 Maltese Lira 2
EUR CYP 0.585274 Cypriot Pound 2
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 289 of 442
From To Rate Currency Decimals
"EUR" "SKK" 30.1260 Slovak Koruna 2
As new member countries adopt the Euro, new conversion rates will become active and evaluators
may add them using the respective ISO 4217 codes and fixed rates as defined by the European
Council, on the basis of a European Commission proposal.
Note:
The European Commission's Euro entry page is http://ec.europa.eu/euro/
The conversion rates and triangulation rules are available at
http://ec.europa.eu/economy_finance/euro/adoption/conversion/index_en.htm with links to the
European Council Regulation legal documents at the http://eur-lex.europa.eu/ European Union law
database server.
If FullPrecision is omitted or False, the result is rounded according to the decimals of the To
currency. If FullPrecision is True the result is not rounded.
If TriangulationPrecision is given and >=3, the intermediate result of a triangular conversion
(currency1,EUR,currency2) is rounded to that precision. If TriangulationPrecision is omitted, the
intermediate result is not rounded. Also if To currency is EUR, TriangulationPrecision precision is
used as if triangulation was needed and conversion from EUR to EUR was applied.
anchor:EUROCONVERT
Test Cases:
Expression Result Comment
=EUROCONVERT(100
;"DEM";"EUR";TRUE())
51.1291881196
Convert German Mark into Euro, full
precision.
=EUROCONVERT(100
;"DEM";"EUR")
51.13
Convert German Mark into Euro,
rounded.
=EUROCONVERT(100
;"DEM";"ATS";FALSE())
703.55
Convert German Mark into Austrian
Schilling, rounded.
=EUROCONVERT(100
;"DEM";"ATS";TRUE())
703.552967282
Convert German Mark into Austrian
Schilling, full precision.
=EUROCONVERT(100
;"DEM";"ATS";TRUE();
5)
703.552993157
Convert German Mark into Austrian
Schilling, full precision and with
triangulation precision 5.
See also CONVERT
Note: This is simply called CONVERT in OOo 2.0.1, with 3 parameters but without triangulation.
OOo 2.0.1's CONVERT_ADD does the job of the CONVERT function defined in this document.
Gnumeric supports EUROCONVERT with 3 parameters. Excel has EUROCONVERT with 5
parameters.
TODO: EUROCONVERT is so-named because these are relatively fixed conversions. It might be
useful to have a CONVERT_MONEY function that can do lookups of tables, invoking
EUROCONVERT in cases where it's appropriate. However, unless there's an existing
implementation, that seems appropriate to add to a future version of this specification.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 290 of 442
6.16.30 EVEN
Summary: Rounds a number up to the nearest even integer. Rounding is away from zero.
Syntax: EVEN( Number N )
Returns: Number
Constraints: None
Semantics: Returns the even integer whose sign is the same as N's and whose absolute value is
greater than or equal to the absolute value of N.
anchor:EVEN
Rationale: There's no need to discuss what happens if N is not a number in this definition; that is
handled in the Conversion to Number section.
Test Cases:
Expression Result Comment
=EVEN(6) 6 Positive even integers remain unchanged.
=EVEN(-4) -4 Negative even integers remain unchanged.
=EVEN(1) 2 Non-even positive integers round up.
=EVEN(0.3) 2 Positive floating values round up.
=EVEN(-1) -2 Non-even negative integers round down.
=EVEN(-0.3) -2 Negative floating values round down.
=EVEN(0) 0 Since zero is even, EVEN(0) returns zero.
See also ODD
6.16.31 EXP
Summary: Returns e raised by the given number.
Syntax: EXP( Number X )
Returns: Number
Constraints: None
Semantics: Computes
e
X
=1+
X
1!
+
X
2
2!
+
X
3
3!
+
X
n
n!
+...
anchor:EXP
Note: Test case 3 implies a very minimal precision requirement for e (i.e. Exp(1)), but this is a trivial
requirement and clearly higher accuracy is better.
Test Cases:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 291 of 442
Expression Result Comment
=EXP(0) 1 Anything raised to the 0 power is 1.
=EXP(LN(2)) 2
The EXP function is the inverse of the LN
function.
=EXP(1)
2.71828182
845904523
536
The value of the natural logarithm e.
See also LOG, LN
6.16.32 FACT
Summary: Return factorial (!).
Syntax: FACT( Integer F )
Returns: Number
Constraints: F >= 0
Semantics: Return the factorial
F !=F(F1)( F2)... 1
F(0)=F(1)=1.
anchor:FACT
Test Cases:
Expression Result Comment
=FACT(0) 1 Factorial of 0 is 1
=FACT(1) 1 Factorial of 1 is 1
=FACT(2) 2 Factorial of 2 is 2
=FACT(3) 6 Factorial of 3 is 6
=FACT(-1) Error Requires F >= 0
See also Infix Operator "*", GAMMA
6.16.33 FACTDOUBLE
Summary: Returns double factorial (!!).
Syntax: FACTDOUBLE( Integer F )
Returns: Number
Constraints: F >= 0
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 292 of 442
Semantics: Return
F !=F(F2)(F4)...1
Double factorial is computed by multiplying every other number in the 1..N range, with N always
being included.
anchor:FACTDOUBLE
Test Cases:
Expression Result Comment
=FACTDOUBLE(0) 1 Factorial of 0 is 1
=FACTDOUBLE(1) 1 Factorial of 1 is 1
=FACTDOUBLE(7) 105 7*5*3=105
=FACTDOUBLE(6) 48 6*4*2 = 48
=FACTDOUBLE(-1) Error Requires F >= 0
See also Infix Operator "*", GAMMA, FACT
6.16.34 GAMMA
Summary: Return gamma function value.
Syntax: GAMMA( Number N )
Returns: Number
Constraints: N<>0 and N not a negative integer.
Semantics: Return
(N) =
t
N1
e
t
dt
with (N+1) = N * (N). Note that for non-negative integers N, (N+1) = N! = FACT(N). Note that
GAMMA can accept non-integers.
anchor:GAMMA
Test Cases:
Expression Result Comment
=GAMMA(1) 1 GAMMA(1) is 1
=GAMMA(1.1
0)
0.951351e
-5
GAMMA(1.1) is
0.95135 to first 5 digits
=GAMMA(1.5
0)
0.886231e
-5
GAMMA(1.5) is
0.88623 to first 5 digits
Note: Source of correct values for GAMMA(1.1) and GAMMA(1.5) is the CRC Handbook of
Chemistry and Physics, 63
rd
edition, Page A-106.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 293 of 442
Note: Calculators and the Gamma Function (http://www.rskey.org/gamma.htm) by Viktor T. Toth
discusses how to implement the gamma function.
See also FACT
Note: This is included because FACT cannot portably provide this functionality.
6.16.35 GAMMALN
Summary: Returns the natural logarithm of the GAMMA function.
Syntax: GAMMALN( Number X )
Returns: Number
Constraints: For each X, X > 0
Semantics: Returns the same value as =LN(GAMMA(X))
anchor:GAMMALN
Test Cases:
Expression Result Comment
=GAMMALN(1) 0 GAMMALN of 1 is 0.
=GAMMALN(2) 0 GAMMALN of 2 is 0.
=GAMMALN(3) 0.6931471806 GAMMALN of 3.
=GAMMALN(1.5) -0.1207822376 GAMMALN of 1.5 - negative.
See also GAMMA, FACT
6.16.36 GCD
Summary: Returns the greatest common divisor (GCD)
Syntax: GCD( { NumberSequenceList X }+
)
Returns: Number
Constraints: For all a in X: INT(a) >= 0 and for at least one a in X: INT(a)>0
Semantics: Return the largest integer N such that for every a in X: INT(a) is a multiple of N.
Note: If for all a in X: INT(a)=0 the return value is implementation-defined but is either an Error or 0.
anchor:GCD
Test Cases:
Expression Result Comment
=GCD(5;15;25) 5 Can handle more than two parameters
=GCD(2;3) 1 Values that
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 294 of 442
=GCD(18;24) 6
=GCD(18.1;24.1) 6 Fractions have INT first.
=GCD(18.9;24.9) 6 Fractions have INT first
=GCD(7) 7 GCD of one number is itself
=GCD(5;0) 5 GCD of a number and 0 is the number.
=GCD(0;0) 0 GCD of zeros only is 0.
=GCD(-2;3) Error Negative numbers are not supported
See also LCM
Note: The GCD function is often implemented using the Euclidean algorithm, one of the world's
oldest algorithms.
Note: OpenOffice.org 2.0.3 considers the full number, it computes GCD(1.1;2.2) as 1.1, and
GCD(18.1;24.1) as 7.11E-015. It has both a GCD and a GCD_ADD, where GCD_ADD applies INT()
first. However, in January 2007, OpenOffice.org implementors agreed in OpenFormula discussions
to change GCD() to apply INT() to its arguments first, making the function compatible with other
implementations. Thus, this is another example of standards efforts between multiple suppliers
resulting in a more compatible, agreed-on definition.
6.16.37 GESTEP
Summary: Returns 1 if a number is greater than or equal to another number, else returns 0.
Syntax: GESTEP( Number X [ ; Number Step = 0 ] )
Returns: Number
Semantics: Number X is tested against number Step. If greater or equal 1 is returned, else 0. The
second parameter is assumed 0 if omitted. If one of the parameters is not a Number, the function
results in an Error.
anchor:GESTEP
Test Cases:
Expression Result Comment
=GESTEP(2;1) 1
=GESTEP(-1;-2) 1 Negative arguments are valid
=GESTEP(1) 1 Second parameter assumed 0 if omitted
=GESTEP(-2;1) 0
=GESTEP(3;3) 1 Number identical to step value.
=GESTEP(1.3;1.2) 1 Floating point values where X is greater than Step.
=GESTEP(-2;"xxx") Error "xxx" is not a number
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 295 of 442
=GESTEP("xxx";-2) Error "xxx" is not a number
See also
6.16.38 LCM
Summary: Returns the least common multiplier
Syntax: LCM( { NumberSequenceList X }
+
)
Returns: Number
Constraints: For all in X: INT(X)=X, X >= 0
Semantics: Return the smallest integer that is the multiple of the given values. Each value has INT
applied to it first. Note that if given two numbers, ABS(a*b)=LCM(a;b)*GCD(a;b).
anchor:LCM
Test Cases:
Expression Result Comment
=LCM(5;15;25) 75 LCM accepts 3 or more numbers.
=LCM(2;3) 6
=LCM(18;12) 36
=LCM(18.1;12.1) 36
=LCM(18.9;12.9) 36
=LCM(7) 7
=LCM(5;0) 0 If any argument is 0 the result is 0.
=LCM(-2;4) Error
See also GCD
Note: OpenOffice.org 2.0.3 accepts non-integers and handles them specially, but its implementors
have agreed to change this. See GCD for more information.
6.16.39 LN
Summary: Return the natural logarithm of a number.
Syntax: LN( Number X )
Returns: Number
Constraints: X>0
Semantics: Computes the natural logarithm (base e) of the given number.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 296 of 442
ln x=2
|
x1
x+1
+
1
3
(
x1
x+1
)
3
+
1
5
(
x1
x+1
)
5
+...
anchor:LN
Test Cases:
Expression Result Comment
=LN(1) 0 The logarithm of 1 (in any base) is 0.
=LN(EXP(1)) 1 The natural logarithm of e is 1.
=LN(20)
2.99573227
4
Trivial test
=LN(0.2)
-
1.60943791
2
This tests a value between 0 and 0.5. Values in this domain
are valid, but implementations that compute LN(x) by blindly
summing the series (1/n)((x-1)/x)^n won't get this value
correct, because that series requires x > 0.5.
=LN(0) Error The argument must be greater than zero.
=LN([.B7]) Error The natural logarithm of a non-number gives an error.
See also LOG, LOG10, POWER, EXP
6.16.40 LOG
Summary: Return the logarithm of a number in a specified base.
Syntax: LOG( Number N [ ; Number Base = 10 ] )
Returns: Number
Constraints: N > 0
Semantics: Computes the logarithm of a number in the specified base. Note that if the base is not
specified, the logarithm base 10 is returned.
anchor:LOG
Test Cases:
Expression Result Comment
=LOG(1; 10) 0 The logarithm of 1 (in any base) is 0.
=LOG(1;EXP(1)) 0 The natural logarithm of 1 is 0.
=LOG(10;10) 1 The base 10 logarithm of 10 is 1.
=LOG(10) 1 If the base is not specified, base 10 is assumed.
=LOG(8*8*8;8) 3 Log base 8 of 8^3 should return 3.
=LOG(0;10) Error The argument must be greater than zero.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 297 of 442
See also LOG10, LN, POWER, EXP
Note: OOo2 requires the base for log, instead of allowing it to be optional. Excel, etc. consider them
optional. Making LOG's second argument optional will require a change to OOo.
6.16.41 LOG10
Summary: Return the base 10 logarithm of a number.
Syntax: LOG10( Number N )
Returns: Number
Constraints: N > 0
Semantics: Computes the base 10 logarithm of a number.
anchor:LOG10
Test Cases:
Expression Result Comment
=LOG10(1) 0 The logarithm of 1 (in any base) is 0.
=LOG10(10) 1 The base 10 logarithm of 10 is 1.
=LOG10(100) 2 The base 10 logarithm of 100 is 2.
=LOG10(0) Error The argument must be greater than zero.
=LOG10("H") Error The logarithm of a non-number gives an error.
See also LOG, LN, POWER, EXP
6.16.42 MOD
Summary: Return the remainder when one number is divided by another number.
Syntax: MOD( Number a ; Number b )
Returns: Number
Constraints: b != 0
Semantics: Computes the remainder of a/b. The remainder has the same sign as b.
anchor:MOD
Test Cases:
Expression Result Comment
=MOD(10;3) 1 10/3 has remainder 1.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 298 of 442
=MOD(2;8) 2 2/8 is 0 remainder 2.
=MOD(5.5;2.5) 0.5 The numbers need not be integers.
=MOD(-2;3) 1 The location of the sign matters.
=MOD(2;-3) -1 The location of the sign matters.
=MOD(-2;-3) -2 The location of the sign matters.
=MOD(10;0) Error Division by zero is not allowed
Note: MOD with negative numbers is tricky. The tests for MOD(-2;3), MOD(2;-3), and MOD(-2;-3)
work with Gnumeric, OOo2, and Excel 2002 as shown. KSpread 1.4.2 also computes MOD(-2;3) as
1. However, KSpread 1.4.2 (on Fedora Core 4) computed MOD(-2;-3) as -5 (not -1), and MOD(2;-3)
computes as 2 (not -1). On January 9, 2006, KSpread developer Tomas Mecir announced that
KSpread's development version had been changed, and the next release of KSpread would
produce the same results with these other negative values.
See also Infix Operator "/", QUOTIENT
6.16.43 MULTINOMIAL
Summary: Returns the multinomial for the given values.
Syntax: MULTINOMIAL( { NumberSequence A }
+
)
Returns: Number
Constraints: None
Semantics: Returns the multinomial of the sequence A = (a1, a2, ..., an). Multinomial is defined as
FACT(a1+a2+...+an) / (FACT(a1)*FACT(a2)*...*FACT(an))
anchor:MULTINOMIAL
Test Cases:
Expression Result Comment
=MULTINOMIAL(7) 1 One parameter always return 1
=MULTINOMIAL(4;2;3) 1260 Rounding down.
See also FACT
6.16.44 ODD
Summary: Rounds a number up to the nearest odd integer, where "up" means "away from 0".
Syntax: ODD( Number N )
Returns: Number
Constraints: None
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 299 of 442
Semantics: Returns the odd integer whose sign is the same as N's and whose absolute value is
greater than or equal to the absolute value of N. In other words, any "rounding" is away from zero.
By definition, ODD(0) is 1.
anchor:ODD
Rationale: There's no need to discuss what happens if N is not a number in this definition; that is
handled in the Conversion to Number section.
Test Cases:
Expression Result Comment
=ODD(5) 5 Positive odd integers remain unchanged.
=ODD(-5) -5 Negative odd integers remain unchanged.
=ODD(2) 3 Non-odd positive integers round up.
=ODD(0.3) 1 Positive floating values round up.
=ODD(-2) -3 Non-odd negative integers round down.
=ODD(-0.3) -1 Negative floating values round down.
=ODD(0) 1 By definition, ODD(0) is 1.
See also EVEN
6.16.45 PI
Summary: Return the approximate value of Pi.
Syntax: PI()
Returns: Number
Constraints: None.
Semantics: This function takes no arguments and returns the (approximate) value of pi. Evaluators
should use the closest possible numerical representation that is possible in their representation of
numbers.
anchor:PI
Note: The test case below implies a very minimal precision requirement for e (i.e. Exp(1)), but this is
a trivial requirement and clearly higher accuracy is better.
Test Cases:
Expression Result Comment
=PI() 3.1415926
535897932
384626433
8327950
The approximate value of pi. Lots of
digits given here, in case the
implementation can actually handle that
many, but implementations are not
required to exactly store this many
digits. PI() should return the closest
possible numeric representation in a
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 300 of 442
fixed-length representation.
See also SIN, COS
6.16.46 POWER
Summary: Return the value of one number raised to the power of another number.
Syntax: POWER( Number a ; Number b )
Returns: Number
Constraints: None
Semantics: Computes a raised to the power b.
POWER(0,0) is implementation-defined, but shall be one of 0,1, or an Error.
POWER(0,b), where b < 0, shall return an Error.
POWER(a,b), where a<=0 and INT(b)!=b, is implementation-defined.
anchor:POWER
Test Cases:
Expression Result Comment
=POWER(10;0) 1 Anything raised to the 0 power is 1.
=POWER(2;8) 256 2^8 is 256.
See also LOG, LOG10, LN, EXP
6.16.47 PRODUCT
Summary: Multiply the set of numbers, including all numbers inside ranges
Syntax: PRODUCT( { NumberSequence N }
+
)
Returns: Number
Constraints: None
Semantics: Returns the product of the Numbers (and only the Numbers, i.e., not Text inside
ranges). This is equivalent to SUM except that it uses the * operator instead of +.
anchor:PRODUCT
Test Cases:
Expression Result Comment
=PRODUCT(2;3;4) 24 Multiply all the numbers.
=PRODUCT(TRUE(
);2;3)
6 TRUE() is 1 if inline.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 301 of 442
=PRODUCT([.B4:.B
5])
6 2*3 is 6.
=PRODUCT([.B3:.B
6])
6
In level 2 and higher, conversion to NumberSequence ignores
Text (in B3) and Logical values (a TRUE() in B6).
=PRODUCT() 0 Product with no parameters returns 0
TBD: OOo 2.0 gives an Error when a non-Number is included in the list, e.g. product(2;3;"2").
Gnumeric seems to ignore non-Numbers, even if they can be converted to a Number, but does not
give an Error, e.g. product(2,3,"2") gives 6. Excel 2002 converts these in-line values to Numbers, so
product(2,3,"2") produces 12.
Note: Lotus1-2-3v9 gives an Error for PRODUCT().
See also SUM
6.16.48 QUOTIENT
Summary: Return the integer portion of a division.
Syntax: QUOTIENT( Number A ; Number B )
Returns: Number
Constraints: B <> 0
Semantics: Return the integer portion of a division.
anchor:QUOTIENT
Test Cases:
Expression Result Comment
=QUOTIENT(10;5) 2
=QUOTIENT(14;5) 2
=QUOTIENT(-204;-23) 8
=QUOTIENT(-45;8) -5
=QUOTIENT(24;-5) -4
=QUOTIENT(21;-5) -4
=QUOTIENT(-14;5) -2
=QUOTIENT(5;0) Error
See also MOD
6.16.49 RADIANS
Summary: Convert degrees to radians.
Syntax: RADIANS( Number N )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 302 of 442
Returns: Number
Constraints: None
Semantics: Converts a number in degrees into a number in radians. RADIANS(N) is equal to
N*PI()/180.
anchor:RADIANS
Test Cases:
Expression Result Comment
=RADIANS(180)/PI() 1 180 degrees is PI() radians.
See also DEGREES, PI
6.16.50 RAND
Summary: Return a random number between 0 (inclusive) and 1 (exclusive).
Syntax: RAND()
Returns: Number
Semantics: This function takes no arguments and returns a random number between 0 (inclusive)
and 1 (exclusive). Note that unlike most functions, this function will typically return different values
when called each time with the same (empty set of) parameters.
anchor:RAND
Note: Some random number generators are better than others. At this time there is no particular
requirement for how random the result needs to be. Implementors should typically avoid using built-
in random number generators provided by language libraries, because they are often extremely
poor algorithms.
Test Cases:
Expression Result Comment
=RAND()>=0 True The random number must be [0,1[
=RAND()<1 True The random number must be [0,1[
See also RANDBETWEEN
6.16.51 RANDBETWEEN
Summary: Return a random integer number between A and B.
Syntax: RANDBETWEEN( Integer A ; Integer B )
Returns: Integer
Constraints: A <= B
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 303 of 442
Semantics: The function returns a random integer number between A and B inclusive. Note that
unlike most functions, this function will often return different values when called each time with the
same parameters.
anchor:RANDBETWEEN
Test Cases:
Expression Result Comment
=RANDBETWEEN(8;8) 8 If A=B, return A.
=RANDBETWEEN(5;15)>=5 True Must return value in range
=RANDBETWEEN(5;15)<=15 True Must return value in range
=RANDBETWEEN(15;5)>=5 True Must return value in range
=RANDBETWEEN(15;5)<=15 True Must return value in range
See also RAND
6.16.52 SEC
Summary: Return the secant of an angle specified in radians.
Syntax: SEC( Number N )
Returns: Number
Constraints: None
Semantics: Computes the secant cosine of an angle specified in radians. Equivalent to:
1/COS(N)
anchor:SEC
Test Cases:
Expression Result Comment
=SEC(PI()/2) 1 Exists
See also SIN
6.16.53 SERIESSUM
Summary: Returns the sum of a power series.
Syntax: SERIESSUM( Number X ; Number N ; Number M ; Array Coefficients )
X: the independent variable of the power series.
N: the initial power to which X is to be raised.
M: the increment by which to increase N for each term in the series.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 304 of 442
Coefficients: a set of coefficients by which each successive power of the variable X is multiplied.
Returns: Number
Constraints:
All elements of Coefficients are of type Number.
X < > 0 if any of the exponents, which are generated from N and M, are negative.
Semantics: Returns a sum of powers of the number X.
With C being the number of coefficients the function is computed as:
SERIESSUM=
i =1
C
Coefficient
i
X
( N +(i 1)M)
If X=0 and all of the exponents are non-negative then
0
0
shall be set to 1 and
0
(exponent >0)
shall be
set to 0.
anchor:SERIESSUM
Test Cases:
Expression Result Comment
=SERIESSUM(3;1;2;[.C51:.C57]) 33628062
6.16.54 SIGN
Summary: Return the sign of a number
Syntax: SIGN( Number N )
Returns: Number
Constraints: None
Semantics: If N < 0, returns -1; if N > 0, returns +1; if N == 0, returns 0.
anchor:SIGN
Test Cases:
Expression Result Comment
=SIGN(-4) -1 N < 0 returns -1
=SIGN(4) 1 N > 0 returns +1
=SIGN(0) 0 N == 0 returns 0
See also ABS
Note: This is placed at level 2, not level 1, because Sheet To Go version 6 doesn't include this
function. It can be trivially implemented using IF for level 1.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 305 of 442
6.16.55 SIN
Summary: Return the sine of an angle specified in radians
Syntax: SIN( Number N )
Returns: Number
Constraints: None
Semantics: Computes the sine of an angle specified in radians.
sin( N )=N
N
3
3!
+
N
5
5!
N
7
7!
+...
anchor:SIN
Test Cases:
Expression Result Comment
=SIN(0) 0
Sine of 0 is 0; this is required to be exact, since some
documents may depend on getting this identity exactly
correct.
=SIN(PI()/4.0)*2/SQRT(2) 1 sine of PI()/4 radians is SQRT(2)/2.
=SIN(PI()/2.0) 1 sine of PI()/2 radians is 1.
See also ASIN, RADIANS, DEGREES
6.16.56 SINH
Summary: Return the hyperbolic sine of the given hyperbolic angle
Syntax: SINH( Number N )
Returns: Number
Constraints: None
Semantics: Computes the hyperbolic sine of a hyperbolic angle. The hyperbolic sine is an analog of
the ordinary (circular) sine. The points (cosh t, sinh t) define the right half of the equilateral
hyperbola, just as the points (cos t, sin t) define the points of a circle.
sinh(N )=
e
N
e
N
2
anchor:SINH
Test Cases:
Expression Result Comment
=SINH(0) 0 Sinh(0) is 0
=SINH(1)
1.17520119
36
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 306 of 442
=SINH(EXP(1))
7.54413710
28
See also ASINH, COSH, TANH
6.16.57 SECH
Summary: Return the hyperbolic secant of the given angle specified in radians
Syntax: SECH( Number N )
Returns: Number
Constraints: None
Semantics: Computes the hyperbolic secant of a hyperbolic angle. This is equivalent to:
1/COSH(N)
anchor:SECH
Test Cases:
Expression Result Comment
=SECH(0) 1 Function exists
See also SINH, CSCH
6.16.58 SQRT
Summary: Return the square root of a number
Syntax: SQRT( Number N )
Returns: Number
Constraints: N>=0
Semantics: Returns the square root of a non-negative number. This function shall produce an Error
if given a negative number; for producing complex numbers, see IMSQRT.
anchor:SQRT
Test Cases:
Expression Result Comment
=SQRT(4) 2 The square root of 4 is 2.
=SQRT(-4) Error The argument must be non-negative
See also POWER, IMSQRT, SQRTPI
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 307 of 442
6.16.59 SQRTPI
Summary: Return the square root of a number multiplied by pi.
Syntax: SQRTPI( Number N )
Returns: Number
Constraints: N>=0
Semantics: Returns the square root of a non-negative number after it was first multiplied by PI, that
is, SQRT(N*PI()). This function shall produce an Error if given a negative number; for producing
complex numbers, see IMSQRT.
anchor:SQRTPI
Test Cases:
Expression Result Comment
=SQRTPI(1) 1.77245385 The square root of
=SQRTPI(2) 2.5066282746 The square root of 2
=SQRTPI(-4) Error The argument must be non-negative
See also POWER, SQRT, PI, IMSQRT
6.16.60 SUBTOTAL
Summary: Evaluates a function on a range.
Syntax: SUBTOTAL( Integer function ; NumberSequence sequence )
Returns: Number
Constraints: None
Semantics: Computes a given function on a number sequence. Function is denoted by the first
parameter: The difference from standard functions is that all members of the sequence are excluded
which:
include a call to SUBTOTAL in their formula
are in a row that is hidden by a table:visibility=filter attribute of the
<table:table-row> element.
are in a row that is hidden by a table:visibility=collapse attribute of the
<table:table-row> element if the function ID is one of 101...111.
Function Exclude hidden by filter Exclude hidden by filter or
collapsed
AVERAGE 1 101
COUNT 2 102
COUNTA 3 103
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 308 of 442
MAX 4 104
MIN 5 105
PRODUCT 6 106
STDEV 7 107
STDEVP 8 108
SUM 9 109
VAR 10 110
VARP 11 111
anchor:SUBTOTAL
Test Cases:
Expression Result Comment
=SUBTOTAL(1;7) 7 Average.
=SUBTOTAL(2;8) 1 Count.
See also SUM, AVERAGE
6.16.61 SUM
Summary: Sum (add) the set of numbers, including all numbers in ranges
Syntax: SUM( { NumberSequenceList N }
+
)
Returns: Number
Constraints: N != {}; Evaluators may evaluate expressions that do not meet this constraint.
Semantics: Adds Numbers (and only Numbers) together (see the text on conversions).
anchor:SUM
Test Cases:
Expression Result Comment
=SUM(1;2;3) 6 Simple sum.
=SUM(TRUE();2;3) 6 TRUE() is 1.
=SUM([.B4:.B5]) 5 2+3 is 5.
See also AVERAGE
Note: The exact semantics of SUM() in Excel are defined in (Walkenbach, 2004, pg 705). Lotus 1-2-
3v9.8.1 does not accept SUM with no parameters.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 309 of 442
6.16.62 SUMIF
Summary: Sum the values of cells in a range that meet a criteria.
Syntax: SUMIF( ReferenceList|Reference R ; Criterion C [ ; Reference S ] )
Returns: Number
Constraints: Does not accept constant values as the range parameter.
Semantics: Sums the values of type Number in the range R or S that meet the Criterion C (4.11.7).
If S is not given, R may be a reference list. If S is given, R shall not be a reference list with more
than 1 references and an Error be generated if it was.
If the optional range S is included, then the values of S starting from the top left cell and matching
the geometry of R (same number of rows and columns) are summed if the corresponding value in R
meets the Criterion. The actual range S is not considered. If the resulting range exceeds the sheet
bounds, column numbers larger than the maximum column and row numbers larger than the
maximum row are silently ignored, no Error is generated for this case.
The values returned may vary depending upon the HOST-USE-REGULAR-EXPRESSIONS or
HOST-USE-WILDCARDS properties. 3.4
anchor:SUMIF
Test Cases:
Expression Result Comment
=SUMIF([.B4:.B5];">2.5") 3
B4 is 2 and B5 is 3, so only B5 has a value greater than
2.5.
=SUMIF([.B3:.B5];[.B4]) 2 Test if a cell equals the value in [.B4].
=SUMIF("";[.B4]) Error Constant values are not allowed for the range.
=SUMIF([.B3:.B4];"7") 0 [.B3] is the string "7", but only numbers are summed.
=SUMIF([.B3:.B4];"7";
[.B4:.B5])
2
[.B3] is the string "7", but its match is mapped to [.B4] for
the summation.
=SUMIF([.B3:.B10];1+1) 2 The criteria can be an expression.
TBD: SUMIF([.B3:.B10];"7";[.B4:.B5]) produces 2 in Excel 2002 and OOo2, but Gnumeric returns a
0. The test is currently set to level 2 because of the difference. Are the strings ("7") being converted
to numbers before comparison in excel and OOo2? Or are they doing a string comparison? This
difference is also encountered in COUNTIF.
See also COUNTIF, SUM, Infix Operator "=", Infix Operator "<>", Infix Operator Ordered
Comparison ("<", "<=", ">", ">=")
6.16.63 SUMIFS
Summary: Sum the values of cells in a range that meet multiple criteria in multiple ranges.
Syntax: SUMIFS( Reference R ; Reference R1 ; Criterion C1 [ ; Reference R2 ; Any C2 ]... )
Returns: Number
Constraints: Does not accept constant values as the reference parameter.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 310 of 442
Semantics: Sums the value of cells in range R that meet the Criterion C1 in the reference range R1
and the Criterion C2 in the reference range R2, and so on (4.11.7). All reference ranges shall have
the same dimension and size, else an Error is returned. A logical AND is applied between each array
result of each selection; an entry is counted only if the same position in each array is the result of a
criteria match.
The values returned may vary depending upon the HOST-USE-REGULAR-EXPRESSIONS or
HOST-USE-WILDCARDS properties. 3.4
anchor:SUMIFS
See also COUNTIFS, SUMIF, Infix Operator "=", Infix Operator "<>", Infix Operator Ordered
Comparison ("<", "<=", ">", ">=")
6.16.64 SUMPRODUCT
Summary: Returns the sum of the products of the matrix elements.
Syntax: SUMPRODUCT( { ForceArray Array A }
+
)
Returns: Number
Constraints: All matrices shall have the same dimensions.
Semantics: Multiplies the corresponding elements of all matrices and returns the sum of them.
SUMPRODUCT( A
1
, A
2
,... , A
K
)=
m=1
M
n=1
N
(
k=1
K
a
k ,mn
)
where
a
k ,mn
denotes an element of the matrix
A
K
.
anchor:SUMPRODUCT
Test Cases:
Expression Result Comment
=SUMPRODUCT([.B4:.C5]) 14 only one parameter gives us just the sum
=SUMPRODUCT([.B4:.C5];[.B4:.C5]) 54 = 4 + 9 + 16 + 25
=SUMPRODUCT([.B4:.C5];[.B4:.C5];
[.B4:.C5])
224 = 8 + 27 + 64 + 125
=SUMPRODUCT([.A41:.C43];
[.A41:.C43])
109 = 1 + 4 + 1 + 4 + 16 + 9 + 9 + 49 + 16
=SUMPRODUCT([.B4:.C5];
[.A41:.C43])
Error Matrices must have the same dimensions.
Note: OOo Calc is restricted to max. 30 parameters in this case.
6.16.65 SUMSQ
Summary: Sum (add) the set of squares of numbers, including all numbers in ranges
Syntax: SUMSQ( { NumberSequence N }
+
)
Returns: Number
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 311 of 442
Constraints: N != {}; Evaluators may evaluate expressions that do not meet this constraint.
Semantics: Adds squares of Numbers (and only Numbers) together. See the text on conversions.
anchor:SUMSQ
Test Cases:
Expression Result Comment
=SUMSQ(1;2;3) 14 Simple sum of squares.
=SUMSQ(TRUE();2
;3)
14 TRUE() is 1.
=SUMSQ([.B4:.B5]) 13 2*2+3*3 is 13.
6.16.66 SUMX2MY2
Summary: Returns the sum of the difference between the squares of the matrices A and B.
Syntax: SUMX2MY2( ForceArray Array A ; ForceArray Array B )
Returns: Number
Constraints: Both matrices shall have the same dimensions.
Semantics: Sums up the differences of the corresponding elements squares for two matrices.
SUMX2MY2( A , B)=
m=1
M
n=1
N
(
a
mn
2
b
mn
2
)
anchor:SUMX2MY2
Test Cases:
Expression Result Comment
=SUMX2MY2([.B4:.C5];[.A41:.B42]) 29 2x2 matrices
=SUMX2MY2([.A41:.B42];[.B4:.C5]) -29 exchanged parameters
=SUMX2MY2([.A41:.C43];[.D41:.F43]) 71 3x3 matrices
=SUMX2MY2([.B4:.C5];[.A41:.C43]) Error Matrices must have the same dimensions.
6.16.67 SUMX2PY2
Summary: Returns the total sum of the squares of the matrices A and B.
Syntax: SUMX2PY2( ForceArray Array A ; ForceArray Array B )
Returns: Number
Constraints: Both matrices shall have the same dimensions.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 312 of 442
Semantics: Sums up the squares of each element of the two matrices.
SUMX2PY2( A , B)=
m=1
M
n=1
N
(
a
mn
2
+b
mn
2
)
anchor:SUMX2PY2
Test Cases:
Expression Result Comment
=SUMX2PY2([.B4:.C5];[.A41:.B42]) 79 2x2 matrices
=SUMX2PY2([.A41:.B42];[.B4:.C5]) 79 exchanged parameters
=SUMX2PY2([.A41:.C43];[.D41:.F43]) 147 3x3 matrices
=SUMX2PY2([.B4:.C5];[.A41:.C43]) Error Matrices must have the same dimensions.
6.16.68 SUMXMY2
Summary: Returns the sum of the squares of the differences between matrix A and B.
Syntax: SUMXMY2( ForceArray Array A ; ForceArray Array B )
Returns: Number
Constraints: Both matrices shall have the same dimensions.
Semantics: Sums up the squares of the differences of the corresponding elements for two
matrices.
SUMXMY2( A , B)=
m=1
M
n=1
N
(
a
mn
b
mn
)
2
anchor:SUMXMY2
Test Cases:
Expression Result Comment
=SUMXMY2([.B4:.C5];[.A41:.B42]) 7 2x2 matrices
=SUMXMY2([.A41:.B42];[.B4:.C5]) 7 exchanged parameters
=SUMXMY2([.A41:.C43];[.D41:.F43]) 141 3x3 matrices
=SUMXMY2([.B4:.C5];[.A41:.C43]) Error Matrices must have the same dimensions.
6.16.69 TAN
Summary: Return the tangent of an angle specified in radians
Syntax: TAN( Number N )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 313 of 442
Returns: Number
Constraints: None
Semantics: Computes the tangent of an angle specified in radians.
TAN(x) = SIN(x) / COS(x)
anchor:TAN
Test Cases:
Expression Result Comment
=TAN(PI()/4.0) 1 tangent of PI()/4.0 radians.
See also ATAN, ATAN2, RADIANS, DEGREES, SIN, COS, COT
6.16.70 TANH
Summary: Return the hyperbolic tangent of the given hyperbolic angle
Syntax: TANH( Number N )
Returns: Number
Constraints: None
Semantics: Computes the hyperbolic tangent of a hyperbolic angle. The hyperbolic tangent is an
analog of the ordinary (circular) tangent. The points (cosh t, sinh t) define the right half of the
equilateral hyperbola, just as the points (cos t, sin t) define the points of a circle.
tanh( N )=
sinh( N )
cosh( N )
=
e
N
e
N
e
N
+e
N
anchor:TANH
Test Cases:
Expression Result Comment
=TANH(0) 0 tanh(0) is 0
=TANH(1)
0.76159415
5955765
=TANH(-1)
-
0.76159415
5955765
=TANH(EXP(1))
0.99132891
58
See also ATANH, SINH, COSH, FISHERINV
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 314 of 442
6.17 Rounding Functions
6.17.1 General
Rounding functions convert an arbitrary Number into an Integer.
Note: Typical implementations of rounding functions first round the internal number representation
to the nearest integer if it is numerically adjacent to it in the numerical representation, then they
perform rounding. Thus, INT((1/3)*3) becomes 1. Some of these functions have bizarre semantics.
6.17.2 CEILING
Summary: Round a number N up to the nearest multiple of the second parameter, significance.
Syntax: CEILING( Number N [ ; [ Number significance ] [ ; Number mode ] ] )
Returns: Number
Constraints: Both N and significance shall be numeric and have the same sign if not 0.
Semantics: Rounds a number up to a multiple of the second number. If significance is omitted or
an empty parameter (two consecutive ;; semicolons) it is assumed to be -1 if N is negative and +1 if
N is non-negative, making the function act like the normal mathematical ceiling function if mode is
not given or zero. If mode is given and not equal to zero, the amount of N is rounded away from
zero to a multiple of significance and then the sign applied. If mode is omitted or zero, rounding is
toward positive infinity; the number is rounded to the smallest multiple of significance that is equal-
to or greater than N. If any of the two parameters N or significance is zero, the result is zero.
Note: Many application user interfaces have a CEILING function with only two parameters, and
somewhat different semantics than given here (e.g., they operate as if there was a non-zero mode
value). These CEILING functions are inconsistent with the standard mathematical definition of
CEILING.
anchor:CEILING
Test Cases:
Expression Result Comment
=CEILING(2; 1) 2 Rounding an integer returns the integer.
=CEILING(2; 3) 3 Round 2 up to the nearest multiple of 3.
=CEILING(2.5; 1) 3 Round 2.5 up to the next larger integer.
=CEILING(2.5; 2) 4 Round 2.5 up to the nearest multiple of 2.
=CEILING(2.5; 2.2) 4.4 Round 2.5 up to the nearest multiple of 2.2.
=CEILING(-2.5;1) Error Sign of number and significance must match.
=CEILING(-2.5; -1) -2
This is a problem case, different programs get different results.
Some get -3, rounding away from zero instead toward a ceiling.
=CEILING(-2.5; -3 Round away from zero if third parameter given and not 0.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 315 of 442
-1;1)
=CEILING(-2.5;0) 0 Rounding any value to a multiple of 0 results in 0.
=CEILING(0;-1) 0 Rounding 0 to any multiple results in 0.
=CEILING(-1.1) -1
Single-argument version works like standard mathematical
function.
See also FLOOR, INT
Note: In Gnumeric, Kspread and Excel, CEILING(-2.5;-1) gives -3, in OOo it gives -2. Since the
function is supposed to round up, -2 seems like the correct answer. This function follows the strange
round away from zero of Excel only if the third parameter is given.
Note: Kspread 1.5.0 does not pass the CEILING(x;0) test case and generates an Error instead.
Note: Excel 2003 has only a two-parameter CEILING, with very odd semantics that are different
from the standard mathematical meaning. In Excel, CEILING(-2.5; -1) gives -3, not -2. The definition
here requires that some applications translate their CEILING (and FLOOR).
6.17.3 INT
Summary: Rounds a number down to the nearest integer.
Syntax: INT( Number N )
Returns: Number
Constraints: None
Semantics: Returns the nearest integer whose value is less than or equal to N. Rounding is
towards negative infinity.
anchor:INT
Test Cases:
Expression Result Comment
=INT(2) 2 Positive integers remain unchanged
=INT(-3) -3 Negative integers remain unchanged
=INT(1.2) 1 Positive floating values are truncated
=INT(1.7) 1 It doesnt matter if the fractional part is > 0.5
=INT(-1.2) -2 Negative floating values round towards negative infinity
=INT((1/3)*3) 1
Naive users expect INT to "correctly" make integers even if there are
limits on precision.
See also ROUND, TRUNC
6.17.4 FLOOR
Summary: Round a number N down to the nearest multiple of the second parameter, significance.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 316 of 442
Syntax: FLOOR( Number N [ ; [ Number significance ] [ ; Number mode ] ] )
Returns: Number
Constraints: Both N and significance shall be numeric and have the same sign.
Semantics: Rounds a number down to a multiple of the second number. If significance is omitted or
an empty parameter (two consecutive ;; semicolons) it is assumed to be -1 if N is negative and +1 if
N is non-negative, making the function act like the normal mathematical floor function if mode is not
given or zero. If mode is given and not equal to zero, the amount of N is rounded toward zero to a
multiple of significance and then the sign applied. Otherwise, it rounds toward negative infinity, and
the result is the largest multiple of significance that is less than or equal to N. If any of the two
parameters N or significance is zero, the result is zero.
Note: Many application user interfaces have a FLOOR function with only two parameters, and
somewhat different semantics than given here (e.g., they operate as if there was a non-zero mode
value). These FLOOR functions are inconsistent with the standard mathematical definition of
FLOOR.
anchor:FLOOR
Test Cases:
Expression Result Comment
=FLOOR(2; 1) 2 Rounding an integer returns the integer.
=FLOOR(2.5; 1) 2 Round 2.5 down to the next smaller integer.
=FLOOR(5; 2) 4 Round 5 down to the nearest multiple of 2.
=FLOOR(5; 2.2) 4.4 Round 5 down to the nearest multiple of 2.2.
=FLOOR(-2.5;1) Error Sign of number and significance must match.
=FLOOR(-2.5; -1) -3
This is a problem case, different programs get different results.
Some get -2, rounding toward zero instead toward a floor.
=FLOOR(-2.5; -1;1) -2 Round toward zero if third parameter given and not 0.
=FLOOR(-2.5;0) 0 Rounding any value to a multiple of 0 results in 0.
=FLOOR(0;-1) 0 Rounding 0 to any multiple results in 0.
=FLOOR(-1.1) -2 Rounds down toward negative infinity with one argument
See also CEILING, INT
Note: In Gnumeric and Excel, FLOOR(-2.5;-1) gives -2, in OOo it gives -3. Since the function is
supposed to round down, -3 seems like the correct answer. Kspread FLOOR(-2.5) gives -3. This
function follows the strange round toward zero only if the third parameter is given.
Note: Kspread 1.5.0 implements FLOOR with only one parameter.
6.17.5 MROUND
Summary: Rounds the number to given multiple.
Syntax: MROUND( Number a ; Number b )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 317 of 442
Returns: Number
Constraints: None
Semantics: Returns the number X, for which the following holds: X/b=INT(X/b) (b divides X), and
for any other Y with the same property, ABS(Y-a)>=ABS(X-a). In case that two such X exist, the
greater one is the result. In less formal language, this function rounds the number a to multiples of
b.
anchor:MROUND
Test Cases:
Expression Result Comment
=MROUND(1564;100) 1600 Rounding up.
=MROUND(1520;100) 1500 Rounding down.
=MROUND(1550;100) 1600 Exactly at .5, rounding up.
=MROUND(41.89;8) 40 Can round to any multiples.
See also ROUND
6.17.6 ROUND
Summary: Rounds the value X to the nearest multiple of the power of 10 specified by Digits.
Syntax: ROUND( Number X [ ; Number Digits = 0 ] )
Returns: Number
Constraints: None
Semantics: Round number X to the precision specified by Digits. The number X is rounded to the
nearest power of 10 given by 10
Digits
. If Digits is zero, or absent, round to the nearest decimal
integer. If Digits is non-negative, round to the specified number of decimal places. If Digits is
negative, round to the left of the decimal point by -Digits places. If X is halfway between the two
nearest values, the result shall round away from zero. Note that if X is a Number, and Digits <= 0,
the results will always be an integer (without a fractional component).
anchor:ROUND
Test Cases:
Expression Result Comment
=ROUND(10.1; 0) 10 If b is not specified, round to the nearest integer.
=ROUND(9.8;0) 10 Round to nearest value (different than INT)
=ROUND(0.5; 0) 1 0.5 rounds up, away from zero.
=ROUND(1/3;0) 0 Round to the nearest integer.
=ROUND(1/3;1) 0.3 Round to one decimal place.
=ROUND(1/3;2) 0.33 Round to two decimal places.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 318 of 442
=ROUND(1/3;2.9) 0.33 If b is not an integer, it is truncated.
=ROUND(5555;-1) 5560 Round to the nearest 10.
=ROUND(-1.1; 0) -1 Negative number rounded to the nearest integer
=ROUND(-1.5; 0) -2 Negative number rounds away from zero
=ROUND(-1.5) -2 Default precision is 0
=ROUND(1.1) 1
=ROUND(9.8) 10
See also TRUNC, INT
Note: Excel 2003 requires both parameters. Many other implementations, such as OpenOffice.org,
make the second parameter optional (with a default of 0).
6.17.7 ROUNDDOWN
Summary: Rounds the value X towards zero to the number of digits specified by Digits
Syntax: ROUNDDOWN( Number X [ ; Integer Digits = 0 ] )
Returns: Number
Constraints: None
Semantics: Round X towards zero, to the precision specified by Digits. The number returned is a
multiple of 10
Digits
. If Digits is zero, or absent, round to the largest decimal integer smaller or equal
to X. If Digits is positive, round towards zero to the specified number of decimal places. If Digits is
negative, round towards zero to the left of the decimal point by -Digits places.
anchor:ROUNDDOWN
Test Cases:
Expression Result Comment
=ROUNDDOWN(1.
45673; -2)
1.45
=ROUNDDOWN(1;
0)
1
=ROUNDDOWN(1) 1
=ROUNDDOWN(9;
1)
0
=ROUNDDOWN(9;
0)
9
=ROUNDDOWN(-
1.1)
-2
=ROUNDDOWN(- -2
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 319 of 442
1.9)
See also TRUNC, INT, ROUND, ROUNDUP
Note: Excel 2003 requires both parameters. Many other implementations, such as OpenOffice.org,
make the second parameter optional (with a default of 0).
6.17.8 ROUNDUP
Summary: Rounds the value X away from zero to the number of digits specified by Digits
Syntax: ROUNDUP( Number X [ ; Integer Digits = 0 ] )
Returns: Number
Constraints: None
Semantics: Round X away from zero, to the precision specified by Digits. The number returned is a
multiple of 10
Digits
. If Digits is zero, or absent, round to the smallest decimal integer larger or equal
to X. If Digits is positive, round away from zero to the specified number of decimal places. If Digits is
negative, round away from zero to the left of the decimal point by -Digits places.
anchor:ROUNDUP
Test Cases:
Expression Result Comment
=ROUNDUP(1.4567
3; -2)
1.46
=ROUNDUP(1.1;0) 2
=ROUNDUP(1.9;0) 2
=ROUNDUP(1) 1
=ROUNDUP(9;1) 10
=ROUNDUP(9;0) 9
=ROUNDUP(-1.1) -1
=ROUNDUP(-1.9) -1
See also TRUNC, INT, ROUND, ROUNDDOWN
Note: Excel 2003 requires both parameters. Many other implementations, such as OpenOffice.org,
make the second parameter optional (with a default of 0).
6.17.9 TRUNC
Summary: Truncate a number to a specified number of digits.
Syntax: TRUNC( Number a ; Number b )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 320 of 442
Returns: Number
Constraints: None
Semantics: Truncate number a to the number of digits specified by b. If b is zero, or absent,
truncate to a decimal integer. If b is positive, truncate to the specified number of decimal places. If b
is negative, truncate to the left of the decimal point. If b is not an integer, it is truncated.
anchor:TRUNC
Test Cases:
Expression Result Comment
=TRUNC(10.1) 10 If b is not specified, truncate to the nearest integer.
=TRUNC(0.5) 0 Truncate rather than rounding.
=TRUNC(1/3;0) 0 Truncate to an integer.
=TRUNC(1/3;1) 0.3 Truncate to one decimal place.
=TRUNC(1/3;2) 0.33 Truncate to two decimal places.
=TRUNC(1/3;2.9) 0.33 If b is not an integer, it is truncated.
=TRUNC(5555;-1) 5550 Truncate to the nearest 10.
=TRUNC(-1.1) -1 Negative number truncated to an integer
=TRUNC(-1.5) -1 Negative number truncated to an integer
See also ROUND, INT
6.18 Statistical Functions
6.18.1 General
The following are statistical functions (functions that report information on a set of numbers). Some
functions that could also be considered statistical functions, such as SUM, are listed elsewhere.
6.18.2 AVEDEV
Summary: Calculates the average of the absolute deviations of the values in list.
Syntax: AVEDEV( { NumberSequenceList N }
+
)
Returns: Number
Constraints: None.
Semantics:
1
n
i=1
n
( x
i
x)
anchor:AVEDEV
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 321 of 442
Test Cases:
Expression Result Comment
=AVEDEV(1;2;3;4) 1
See also SUM, AVERAGE
6.18.3 AVERAGE
Summary: Average the set of numbers
Syntax: AVERAGE( { NumberSequence N }
+
)
Returns: Number
Constraints: At least one Number included. Returns an Error if no Numbers provided.
Semantics: Computes SUM(List) / COUNT(List).
anchor:AVERAGE
Test Cases:
Expression Result Comment
=AVERAGE(2;4) 3 Simple average.
See also SUM, COUNT
6.18.4 AVERAGEA
Summary: Average values, including values of type Text and Logical.
Syntax: AVERAGEA( { Any N }
+
)
Returns: Number
Constraints: At least one value included. Returns an Error if no value provided.
Semantics: A variant of the AVERAGE function that includes values of type Text and Logical. Text
values are treated as number 0. Logical True is treated as 1 and False is treated as 0. Empty cells
are not included. Any N may be of type ReferenceList.
anchor:AVERAGEA
Test Cases:
Expression Result Comment
=AVERAGEA(2;4) 3 Simple average.
=AVERAGEA(TRUE();FALSE()
;5)
2
Logical values are treated as 1 and 0 if inline (this
is the same as AVERAGE)
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 322 of 442
See also AVERAGE
Note: AVERAGEA handles Logical values the same way AVERAGE does on implementations
where Logical values are of type Number. By having both AVERAGEA and AVERAGE, we can
record which was intended without loss of information.
6.18.5 AVERAGEIF
Summary: Average the values of cells in a range that meet a criteria.
Syntax: AVERAGEIF( Reference R ; Criterion C [ ; Reference A ] )
Returns: Number
Constraints: Does not accept constant values as reference parameters.
Semantics: If reference A is omitted, averages the values of cells in the reference range R that
meet the Criterion C (4.11.7). If reference A is given, averages the values of cells of a range that is
constructed using the top left cell of reference A and applying the dimensions, shape and size, of
reference R. If no cell in range R matches the Criterion C, an Error is returned. If no Numbers are in
the range to be averaged, an Error is returned.
The values returned may vary depending upon the HOST-USE-REGULAR-EXPRESSIONS or
HOST-USE-WILDCARDS properties. 3.4
anchor:AVERAGEIF
See also AVERAGEIFS, COUNTIF, SUMIF, Infix Operator "=", Infix Operator "<>", Infix Operator
Ordered Comparison ("<", "<=", ">", ">=")
6.18.6 AVERAGEIFS
Summary: Average the values of cells that meet multiple criteria in multiple ranges.
Syntax: AVERAGEIFS( Reference A ; Reference R1 ; Criterion C1 [ ; Reference R2 ; Criterion
C2 ]... )
Returns: Number
Constraints: Does not accept constant values as reference parameters.
Semantics: Averages the values of cells in the reference range A that meet the Criterion C1 in the
reference range R1 and the Criterion C2 in the reference range R2, and so on (4.11.7). All reference
ranges shall have the same dimension and size, else an Error is returned. A logical AND is applied
between each array result of each selection; a cell of reference range A is evaluated only if the
same position in each array is the result of a Criterion match. If no numbers are in the result set to
be averaged, an Error is returned.
The values returned may vary depending upon the HOST-USE-REGULAR-EXPRESSIONS or
HOST-USE-WILDCARDS properties. 3.4
anchor:AVERAGEIFS
See also AVERAGEIF, COUNTIFS, Infix Operator "=", Infix Operator "<>", Infix Operator Ordered
Comparison ("<", "<=", ">", ">=")
6.18.7 BETADIST
Summary: returns the value of the probability density function or the cumulative distribution function
for the beta distribution.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 323 of 442
Syntax: BETADIST( Number x ; Number o ; Number | [ ; Number a = 0 [ ; Number b = 1 [ ; Logical
Cumulative = TRUE() ] ] ] )
Returns: Number
Constraints: o > 0, | > 0, a < b,
If o < 1, then the density function has a pole at x = a.
If | < 1, then the density function has a pole at x = b.
In both cases, if x=a respectively x=b and Cumulative=FALSE(), an Error is returned.
Semantics: If Cumulative is FALSE(), BETADIST returns 0 if x < a or x > b and the value
I(o+)
I(o) I( )
(
x a
ba
)
o1
(
1
x a
ba
)
1
1
ba
otherwise.
If Cumulative is TRUE(), BETADIST returns 0 if x < a, 1 if x > b, and the value
a
x
I(o+)
I(o) I()
(
ta
ba
)
o1
(
1
ta
ba
)
1
1
ba
dt
otherwise.
Note: With substitution
z
t a
ba
the term can be written as
0
xa
ba
I(o+)
I(o) I( )
z
o1
(1z)
1
dz
anchor:BETADIST
Test Cases:
Expression Result Comment
=BETADIST(0;3;4) 0
=BETADIST(0.5;3;4) 0.65625 exact 0.65625
=BETADIST(0.9;4;3) 0.98415 exact 0.98415
=BETADIST(1.5;3;4;1;2) =BETADIST(0.5;3;4) substitution
=BETADIST(2;3;4;1;3) =BETADIST(0.5;3;4) substitution
=BETADIST(0;3;4;0;1;FALSE()) 0
=BETADIST(0.5;3;4;0;1;FALSE()) 1.875 exact 1.875
=BETADIST(0.9;4;3;0;1;FALSE()) 0.4374 exact 0.4374
=BETADIST(1.5;3;4;1;2;FALSE())
=BETADIST(0.5;3;4;0;1;FALS
E())
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 324 of 442
=BETADIST(2;3;4;1;3;FALSE()) 0.9375 exact 0.9375
=BETADIST(2;3;4) 1
=BETADIST(-1;3;4) 0
=BETADIST(2;3;4;0;1;FALSE()) 0
=BETADIST(-1;3;4;0;1;FALSE()) 0
See also BETAINV
Note: Excel, OOo2, Gnumeric and KSpread do not support the last optional argument. They also
have an additional constraint
axb
.
6.18.8 BETAINV
Summary: returns the inverse of BETADIST(x;o;|;a;b;TRUE()).
Syntax: BETAINV( Number p ; Number o ; Number | [ ; Number a = 0 [ ; Number b = 1 ] ] )
Returns: Number
Constraints:
0p1
, o > 0, | > 0, a < b
Semantics: BETAINV returns the unique number x in the closed interval from a to b such that
BETADIST(x;o;|;a;b) = p.
anchor:BETAINV
Test Cases:
Expression Result Comment
=BETADIST(BETAINV(0;3;4);3;4) 0
=BETADIST(BETAINV(0.1;3;4);3;4) 0.1
=BETADIST(BETAINV(0.3;3;4);3;4) 0.3
=BETADIST(BETAINV(0.5;4;3);4;3) 0.5
=BETADIST(BETAINV(0.7;4;3);4;3) 0.7
=BETADIST(BETAINV(1;3;4);3;4) 1
=BETADIST(BETAINV(0;3;4;1;3);3;4;1;3) 0
=BETADIST(BETAINV(0.1;3;4;1;3);3;4;1;3) 0.1
=BETADIST(BETAINV(0.3;3;4;1;3);3;4;1;3) 0.3
=BETADIST(BETAINV(0.5;4;3;1;3);4;3;1;3) 0.5
=BETADIST(BETAINV(0.7;4;3;1;3);4;3;1;3) 0.7
=BETADIST(BETAINV(1;3;4;1;3);3;4;1;3) 1
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 325 of 442
See also BETADIST
6.18.9 BINOM.DIST.RANGE
Summary: Returns the probability of a trial result using binomial distribution.
Syntax: BINOM.DIST.RANGE( Integer N ; Number P ; Integer S [ ; Integer S2 ] )
Returns: Number
Constraints: 0<=P<=1, 0<=S<=S2<=N
Semantics: Let N be a total number of independent trials, and P be a probability of success for
each trial. This function returns the probability that the number of successful trials shall be exactly S.
If the optional parameter S2 is provided, this function returns the probability that the number of
successful trials shall lie between S and S2 inclusive.
This function is computed as follows:
If S2 is not given, let S2:=S. Then the function returns the value of
k =S
S2
(
N
k
)
P
k
(1P)
N k
anchor:BINOM.DIST.RANGE
Test Cases:
Expression Result Comment
=BINOM.DIST.RANGE(10
;1;10)
1 Prob.=100% - all trials successful
=BINOM.DIST.RANGE(10
;1;9)
0 Prob. of -exactly- 9 trials successful is 0 then
=BINOM.DIST.RANGE(7;
0.5;3)
0.2734375 Some values
=BINOM.DIST.RANGE(8;
0.2;3;7)
0.20307698 Some more values, with range.
See also BINOMDIST
Note: This describes how the function works in OOo. KSpread has a similar function, called BINO,
which takes the arguments in a different order, and doesn't have the 4th argument. Gnumeric
doesn't have this function. Excel doesn't have this function.
6.18.10 BINOMDIST
Summary: Returns the binomial distribution.
Syntax: BINOMDIST( Integer S ; Integer N ; Number P ; Logical Cumulative )
Returns: Number
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 326 of 442
Constraints: 0 <= P <= 1; 0 <= S <= N
Semantics: If Cumulative is FALSE(), this function returns the same result as
BINOM.DIST.RANGE(N;P;S). If Cumulative is TRUE(), it is equivalent to calling
BINOM.DIST.RANGE(N;P;0;S).
anchor:BINOMDIST
Test Cases:
Expression Result Comment
=BINOMDIST(10;10;1;0) 1 Prob.=100% - all trials successful
=BINOMDIST(9;10;1;0) 0 Prob. of -exactly- 9 trials successful is 0 then
=BINOMDIST(10;10;0,1;1) 1 Sum of probabilities of 0..10 hits is 1.
=BINOMDIST(4;10;0,4;1) 0.63310326 Some random values.
See also BINOM.DIST.RANGE
6.18.11 LEGACY.CHIDIST
Summary: returns the right-tail probability for the
2
distribution.
Syntax: LEGACY.CHIDIST( Number x ; Number DegreesOfFreedom )
Returns: Number
Constraints: DegreesOfFreedom is a positive integer.
Semantics: In the following n is DegreesOfFreedom. LEGACY.CHIDIST returns 1 for
x<0
and
the value
t
n
2
1
e
t
2
2
n
2
I(n/ 2)
dt
for
x>0
.
anchor:LEGACY.CHIDIST
Test Cases:
Expression Result Comment
=LEGACY.CHIDIST(-1;2) 1
=LEGACY.CHIDIST(0;2) 1
=LEGACY.CHIDIST(2;2) 0.367879
=LEGACY.CHIDIST(4;4) 0.406006
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 327 of 442
See also CHISQDIST, LEGACY.CHITEST
Note: This function differs from the other distribution function in that it calculates the right-hand tail.
6.18.12 CHISQDIST
Summary: returns the value of the probability density function or the cumulative distribution function
for the
2
distribution.
Syntax: CHISQDIST( Number x ; Number DegreesOfFreedom [ ; Logical Cumulative = TRUE() ] )
Returns: Number
Constraints: DegreesOfFreedom is a positive integer.
Semantics: In the following n is DegreesOfFreedom.
If Cumulative is FALSE(), CHISQDIST returns 0 for
x<0
and the value
x
n
2
1
e
x
2
2
n
2
I( n/ 2)
for
x>0
.
If Cumulative is TRUE(), CHISQDIST returns 0 for
x<0
and the value
0
x
t
n
2
1
e
t
2
2
n
2
I(n/ 2)
dt
for
x>0
.
anchor:CHISQDIST
Test Cases:
Expression Result Comment
=CHISQDIST(0;2) 0
=CHISQDIST(0;2;FALSE()) 0
=CHISQDIST(2;2;FALSE()) 0.183940
=CHISQDIST(2;2;TRUE()) 0.632121
=CHISQDIST(4;2;FALSE()) 0.067668
=CHISQDIST(4;2;TRUE()) 0.864665
See also LEGACY.CHIDIST
Note: This is a version of CHIDIST consistent with the other distribution functions.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 328 of 442
6.18.13 LEGACY.CHIINV
Summary: returns the inverse of LEGACY.CHIDIST(x; DegreesOfFreedom).
Syntax: LEGACY.CHIINV( Number p ; Number DegreesOfFreedom )
Returns: Number
Constraints: DegreesOfFreedom is a positive integer and
0p1
.
Semantics: LEGACY.CHIINV returns the unique number x such that LEGACY.CHIDIST(x;
DegreesOfFreedom) = p.
anchor:LEGACY.CHIINV
Test Cases:
Expression Result Comment
=LEGACY.CHIDIST(LEGACY.CHIINV(0.1;3);3) 0.1
=LEGACY.CHIDIST(LEGACY.CHIINV(0.3;3);3) 0.3
=LEGACY.CHIDIST(LEGACY.CHIINV(0.5;3);3) 0.5
=LEGACY.CHIDIST(LEGACY.CHIINV(0.7;3);3) 0.7
=LEGACY.CHIDIST(LEGACY.CHIINV(0.9;3);3) 0.9
=LEGACY.CHIDIST(LEGACY.CHIINV(0.1;20);20) 0.1
=LEGACY.CHIDIST(LEGACY.CHIINV(0.3;20);20) 0.3
=LEGACY.CHIDIST(LEGACY.CHIINV(0.5;20);20) 0.5
=LEGACY.CHIDIST(LEGACY.CHIINV(0.7;20);20) 0.7
=LEGACY.CHIDIST(LEGACY.CHIINV(0.9;20);20) 0.9
=LEGACY.CHIDIST(LEGACY.CHIINV(1;20);20) 1
See also LEGACY.CHIDIST
6.18.14 CHISQINV
Summary: returns the inverse of CHISQDIST(x; DegreesOfFreedom; TRUE()).
Syntax: CHISQINV( Number p ; Number DegreesOfFreedom )
Returns: Number
Constraints: DegreesOfFreedom is a positive integer and
0p1
.
Semantics: CHISQINV returns the unique number
x0
such that CHISQDIST(x;
DegreesOfFreedom;TRUE()) = p.
anchor:CHISQINV
Test Cases:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 329 of 442
Expression Result Comment
=CHISQDIST(CHISQINV(0.1;3);3;TRUE() ) 0.1
=CHISQDIST(CHISQINV(0.3;3);3;TRUE()) 0.3
=CHISQDIST(CHISQINV(0.5;3);3;TRUE()) 0.5
=CHISQDIST(CHISQINV(0.7;3);3;TRUE()) 0.7
=CHISQDIST(CHISQINV(0.9;3);3;TRUE()) 0.9
=CHISQDIST(CHISQINV(0.1;20);20;TRUE()) 0.1
=CHISQDIST(CHISQINV(0.3;20);20;TRUE()) 0.3
=CHISQDIST(CHISQINV(0.5;20);20;TRUE()) 0.5
=CHISQDIST(CHISQINV(0.7;20);20;TRUE()) 0.7
=CHISQDIST(CHISQINV(0.9;20);20;TRUE()) 0.9
=CHISQDIST(CHISQINV(0;20);20;TRUE()) 0
See also CHISQDIST
6.18.15 LEGACY.CHITEST
Summary: Returns some Chi square goodness-for-fit test.
Syntax: LEGACY.CHITEST( ForceArray Array A ; ForceArray Array E )
Returns: Number
Constraints:
ROWS(A) == ROWS(E)
COLUMNS(A) == COLUMNS(E)
COLUMNS(A) * ROWS(A) > 1
Semantics:
For an empty element or an element of type Text or Boolean in A the element at the corresponding
position of E is ignored, and vice versa.
A actual observation data.
E expected values.
First a Chi square statistic is calculated:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 330 of 442
X
2
=
i=1
r
j=1
c
(
A
ij
E
ij )
2
E
ij
with
r = number of rows
c = number of columns
A
ij
= element of actual data
E
ij
= element of expected values
Then LEGACY.CHIDIST is called with the Chi-square value and a degree of freedom (df):
if r>1 and c>1
df =( r1)( c1)
else
df =rc1
LEGACY.CHITEST =LEGACY.CHIDIST (X
2
; df )
anchor:LEGACY.CHITEST
Test Cases:
Expression Result Comment
=CHITEST([.B71:.D73];
[.F71:.H73])
0.992408092
See also LEGACY.CHIDIST
Note: Applications usually describe the CHITEST function as a Chi-square independence test. From
a mathematical point of view this is not correct, as that would not involve testing some actual data
against a set of expected values. It resembles more a Goodness-for-Fit test, but how the degree of
freedom is calculated actually doesn't make sense then. This is specified to be interoperable with
Excel and OpenOffice.org. Gnumeric gets different results if the number of rows and columns both
are greater than 2. See also a comment on OFFICE-2309.
6.18.16 CONFIDENCE
Summary: Returns the confidence interval for a population mean.
Syntax: CONFIDENCE( Number alpha ; Number stddev ; Number size )
Returns: Number
Constraints: 0 < alpha < 1; stddev > 0, size >= 1
Semantics: Calling this function is equivalent to calling NORMINV(1 - alpha / 2; 0; 1) * stddev /
SQRT (size)
anchor:CONFIDENCE
Test Cases:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 331 of 442
Expression Result Comment
=CONFIDENCE(0.5;1;1) 0.67448975 Test values.
=CONFIDENCE(0.25;1;1) 1.15034939 Test values.
=CONFIDENCE(0.5;4;1) 2.697959 Multiplying stddev by X multiplies result by X.
=CONFIDENCE(0.5;1;4) 0.33724488 Multiplying count by X*X divides result by X.
6.18.17 CORREL
Summary: Calculates the correlation coefficient of values in N1 and N2.
Syntax: CORREL( ForceArray Array N1 ; ForceArray Array N2 )
Returns: Number
Constraints: COLUMNS(N1) = COLUMNS(N2), ROWS(N1) = ROWS(N2), both sequences shall
contain at least one number at corresponding positions each.
Semantics: Has the same value as COVAR(N1;N2)/STDEVP(N1)*(STDEVP(N2)). The CORREL
function actually is identical to the PEARSON function.
For an empty element or an element of type Text or Boolean in N1 the element at the corresponding
position of N2 is ignored, and vice versa.
anchor:CORREL
Test Cases:
Expression Result Comment
=CORREL([.B14:.B17];
[.B14:.B17])
1 Perfect positive correlation given identical sequences
=CORREL([.B14:.B17];
[.C14:.C17])
-1 Perfect negative correlation given reversed sequences
=CORREL(1;2) Error Each list must contain at least 2 values
=CORREL([.B14:.B16];
[.B15:.B16])
Error The length of each list must be equal
See also PEARSON
6.18.18 COVAR
Summary: Calculates covariance of two cell ranges.
Syntax: COVAR( ForceArray Array n1 ; ForceArray Array n2 )
Returns: Number
Constraints: COLUMNS(n1) = COLUMNS(n2), ROWS(n1) = ROWS(n2), both sequences shall
contain at least one number at corresponding positions each.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 332 of 442
Semantics: returns
an1, bn2
( an1)( bn2)
where
n1
is the result of calling AVERAGE(n1), and
n2
is the result of calling AVERAGE(n2).
For an empty element or an element of type Text or Boolean in n1 the element at the corresponding
position of n2 is ignored, and vice versa.
anchor:COVAR
Test Cases:
Expression Result Comment
=COVAR([.C11:.C17];[.C11:.C17]) 4.9795918367 Test value.
=COVAR([.B14:.B17];[.C14:.C17]) -1.25 Test values.
=COVAR([.B14:.B17];[.C14:.C18]) Error Array sizes don't match.
6.18.19 CRITBINOM
Summary: Returns the smallest value for which the cumulative binomial distribution is greater than
or equal to a criterion value.
Syntax: CRITBINOM( Number Trials ; Number SP ; Number Alpha )
Returns: Number
Constraints: Trials >=0, 0 <= SP <= 1, Alpha >= 1
Semantics:
Trials is the total number of trials.
SP is the probability of success for one trial.
Alpha is the threshold probability to be reached or exceeded.
anchor:CRITBINOM
Test Cases:
Expression Result Comment
=CRITBINOM(100;0.5;0.1) 44
6.18.20 DEVSQ
Summary: Calculates sum of squares of deviations.
Syntax: DEVSQ( { NumberSequence n }
+
)
Returns: Number
Semantics: returns
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 333 of 442
xn
( xa)
2
where a is the result of calling AVERAGE(n).
anchor:DEVSQ
Test Cases:
Expression Result Comment
=DEVSQ(4) 0 One value - no deviation.
=DEVSQ(5;5;5;5) 0 Identical values - no deviation.
=DEVSQ(2;4) 2 Each value deviates by 1.
=DEVSQ(-5;5;-1;1) 52 Average=0 must work properly.
=DEVSQ([.C11:.C17]) 34.8571428571 Test values.
=DEVSQ([.B14:.B17]) 5.00 Test values.
=DEVSQ([.B14]) 0 One value - no deviation.
6.18.21 EXPONDIST
Summary: returns the value of the probability density function or the cumulative distribution function
for the exponential distribution.
Syntax: EXPONDIST( Number x ; Number i [; Logical Cumulative = TRUE() ] )
Returns: Number
Constraints: i > 0
Semantics: If Cumulative is FALSE(), EXPONDIST returns 0 if x < 0 and the value
\e
\x
otherwise.
If Cumulative is TRUE(), EXPONDIST returns 0 if x < 0 and the value
0
x
\e
\t
dt=1e
\x
otherwise.
anchor:EXPONDIST
Test Cases:
Expression Result Comment
=EXPONDIST(1;1;TRUE()) 0.632121
=EXPONDIST(2;2;TRUE()) 0.981684
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 334 of 442
=EXPONDIST(0;1;TRUE()) 0
=EXPONDIST(-1;1;TRUE()) 0
=EXPONDIST(1;1;FALSE()) 0.367879
=EXPONDIST(2;2;FALSE()) 0.036631
=EXPONDIST(0;1;FALSE()) 1
=EXPONDIST(-1;1;FALSE()) 0
=EXPONDIST(1;1) =EXPONDIST(1;1;TRUE())
6.18.22 FDIST
Summary: returns the value of the probability density function or the cumulative distribution function
for the F-distribution.
Syntax: FDIST( Number x ; Number r1 ; Number r2 [ ; Logical Cumulative = TRUE() ] )
Returns: Number
Constraints: r1 and r2 are positive integers
Semantics:
r1 is the degrees of freedom in the numerator of the F distribution.
r2 is the degrees of freedom in the denominator of the F distribution.
If Cumulative is FALSE(), FDIST returns 0 if x < 0, an Error if the numerator degrees of freedom r1 =
1 and x = 0, and the value
I(
r
1
+r
2
2
)
(
r
1
r
2
)
r
1
2
I(
r
1
2
) I(
r
2
2
)
x
r
1
2
1
(
1+
r
1
r
2
x
)
r
1
+r
2
2
otherwise.
If the numerator degrees of freedom r1 = 1, then the density function has a pole at x=0, the subterm
x
r
1
2
1
=0
0.5
is not defined.
If Cumulative is TRUE(), FDIST returns 0 if x < 0 and the value
I(
r
1
+r
2
2
)
(
r
1
r
2
)
r
1
2
I(
r
1
2
) I(
r
2
2
)
0
x
t
r
1
2
1
(
1+
r
1
r
2
t
)
r
1
+r
2
2
dt
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 335 of 442
otherwise.
anchor:FDIST
Test Cases:
Expression Result Comment
=FDIST(1;4;5) 0.514343
=FDIST(2;5;4) 0.739202
=FDIST(0;4;5) 0
=FDIST(-1;4;5) 0
=FDIST(1;4;5;FALSE()) 0.397614
=FDIST(2;5;4;FALSE()) 0.154000
=FDIST(0;4;5;FALSE()) 0
=FDIST(-1;4;5;FALSE()) 0
=FDIST(1;4;5;TRUE()) =FDIST(1;4;5)
See also LEGACY.FDIST
Note: Ooo2, Gnumeric and KSpread do not support the last argument. They return an Error for
negative x and they calculate the right-hand tail, as does Excel97.
6.18.23 LEGACY.FDIST
Summary: returns the area of the right tail of the probability density function for the F-distribution.
Syntax: LEGACY.FDIST( Number x ; Number r1 ; Number r2 )
Returns: Number
Constraints: r1 and r2 are positive integers
Semantics:
LEGACY.FDIST returns Error if x < 0 and the value
I(
r
1
+r
2
2
)
(
r
1
r
2
)
r
1
2
I(
r
1
2
) I(
r
2
2
)
t
r
1
2
1
(
1+
r
1
r
2
t
)
r
1
+r
2
2
dt
otherwise.
Note that the latter is (1-FDIST(x; r1; r2;TRUE())).
anchor:LEGACY.FDIST
Test Cases:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 336 of 442
Expression Result Comment
=LEGACY.FDIST(1;4;5) 0.485657
=LEGACY.FDIST(2;5;4) 0.260798
=LEGACY.FDIST(0;4;5) 1
=LEGACY.FDIST(-1;4;5) Error
See also FDIST
6.18.24 FINV
Summary: returns the inverse of FDIST(x;r1;r2;TRUE()).
Syntax: FINV( Number p ; Number r1 ; Number r2 )
Returns: Number
Constraints:
0p1
, r1 and r2 are positive integers
Semantics: FINV returns the unique non-negative number x such that FDIST(x;r1;r2) = p.
anchor:FINV
Test Cases:
Expression Result Comment
=FDIST(FINV(0.1;3;4);3;4) 0.1
=FDIST(FINV(0.3;3;4);3;4) 0.3
=FDIST(FINV(0.5;4;3);4;3) 0.5
=FDIST(FINV(0.7;4;3);4;3) 0.7
=FDIST(FINV(0;3;4);3;4) 0
See also FDIST, LEGACY.FDIST, LEGACY.FINV
6.18.25 LEGACY.FINV
Summary: returns the inverse of LEGACY.FDIST(x;r1;r2).
Syntax: LEGACY.FINV( Number p ; Number r1 ; Number r2 )
Returns: Number
Constraints:
0p1
, r1 and r2 are positive integers
Semantics: LEGACY.FINV returns the unique non-negative number x such that
LEGACY.FDIST(x;r1;r2) = p.
anchor:LEGACY.FINV
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 337 of 442
Test Cases:
Expression Result Comment
=LEGACY.FDIST(LEGACY.FINV(0.1;3;4);3;4) 0.1
=LEGACY.FDIST(LEGACY.FINV(0.3;3;4);3;4) 0.3
=LEGACY.FDIST(LEGACY.FINV(0.5;4;3);4;3) 0.5
=LEGACY.FDIST(LEGACY.FINV(0.7;4;3);4;3) 0.7
=LEGACY.FDIST(LEGACY.FINV(1;3;4);3;4) 1
See also FDIST, LEGACY.FDIST, FINV
6.18.26 FISHER
Summary: returns the Fisher transformation.
Syntax: FISHER( Number r )
Returns: Number
Constraints: -1 < r < 1
Semantics: Returns the Fisher transformation with a sample correlation r. This function computes
1
2
ln(
1+r
1r
)
where ln is the natural logarithm function.
FISHER is a synonym for ATANH.
anchor:FISHER
Test Cases:
Expression Result Comment
=FISHER(0) 0 Fisher of 0.
=FISHER((EXP(1)-1)/(EXP(1)+1)) 0.5 Argument chosen so that ln=1
=FISHER(0.5) 0.54930614 Some random value.
=FISHER(0.47)+FISHER(-0.47) 0 Function is symetrical.
See also ATANH
6.18.27 FISHERINV
Summary: returns the inverse Fisher transformation.
Syntax: FISHERINV( Number r )
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 338 of 442
Returns: Number
Constraints: none
Semantics: Returns the inverse Fisher transformation. This function computes
e
2r
1
e
2r
+1
FISHERINV is a synonym for TANH.
anchor:FISHERINV
Test Cases:
Expression Result Comment
=FISHERINV(0) 0 Fisherinv of 0.
=FISHERINV(LN(2)) 0.6 e^(2*ln(2))=4
=FISHERINV(FISHER(0.5)) 0.5 Some random value.
=FISHERINV(0.47)+FISHERINV(-0.47) 0 Function is symetrical.
See also TANH
6.18.28 FORECAST
Summary: Extrapolates future values based on existing x and y values.
Syntax: FORECAST( Number Value ; ForceArray Array Data_Y ; ForceArray Array Data_X )
Returns: Number
Constraints: COLUMNS(Data_Y) = COLUMNS(Data_X), ROWS(Data_Y) = ROWS(Data_X)
Semantics:
Value is the x-value, for which the y-value on the linear regression is to be returned.
Data_Y is the array or range of known y-values.
Data_X is the array or range of known x-values.
For an empty element or an element of type Text or Boolean in Data_Y the element at the
corresponding position of Data_X is ignored, and vice versa.
anchor:FORECAST
Note: This function uses linear regression. How can we codify the specification to be actually useful
without including the whole theory behind it? For the moment, we wont give the details; they are
lengthy, and in any case well-known. Simply stating that it is a linear regression should be
sufficient for the purposes of this spec.
TODO: Test case.
6.18.29 FREQUENCY
Summary: Categorizes values into intervals and counts the number of values in each interval.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 339 of 442
Syntax: FREQUENCY( NumberSequenceList data ; NumberSequenceList bins )
Returns: Array
Constraints: Values in bins shall be sorted in ascending order and bins shall be a column vector.
Evaluators may accept unsorted values in bins.
Semantics: Counts the number of values for each interval given by the border values in bins .
The values in bins determine the upper boundaries of the intervals. The intervals include the upper
boundaries. The returned array is a column vector and has one more element than bins ; the last
element represents the number of all elements greater than the last value in bins . If bins is empty,
all values in data are counted. The values in the result array are ordered matching the original order
of bins . If the values in bins are not sorted in ascending order, they are sorted internally to form
category intervals and the counts of data values are "unsorted" to the original order of bins. If data is
empty, the value of all elements in the returned array is 0.
data The data, that should be categorized and counted according to the given intervals.
bins The upper boundaries determining the intervals the values in data should be grouped by.
anchor:FREQUENCY
Test Cases:
Expression Result Comment
=FREQUENCY([.C19:.C31]; [.B14:.B17]) 3 bins were sorted ascending
2
1
2
5
=FREQUENCY([.C19:.C31]; [.C14:.C17]) 2 bins were sorted descending
1
2
3
5
6.18.30 FTEST
Summary: Calculates the probability of an F-test.
Syntax: FTEST( ForceArray NumberSequence Data_1 ; ForceArray NumberSequence Data_2 )
Returns: Number
Constraints: Data_1 and Data_2 shall both contain at least 2 numbers and shall both have nonzero
variances
Semantics: Calculates the two-tailed probability that, based on two samples from two normal
distributions, these normal distributions have different variances.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 340 of 442
Suppose the first sample has size n1 and sample variance s1^2 and the second sample has size n2
and sample variance s2^2. If s1^2>s^2 FDIST returns twice the area of the right tail of the F-
distribution with degrees of freedom n1-1,n2-1 beyond s^1/s^2. If s1^2<s^2 FDIST returns twice the
area of the left tail of the F-distribution with degrees of freedom n1-1,n2-1 below s^1/s^2.
anchor:FTEST
Test Cases:
Expression Result Comment
=FTEST(B14:B17; C14:C17) 1
Same data (second reversed), so
equal variances
=FTEST(B14:B15; C13:C14)
0.311916521
o
I(o)
x
o1
e
otherwise.
If Cumulative is TRUE(), GAMMADIST returns 0 if x < 0 and the value
0
x
1
o
I(o)
t
o1
e
dt
otherwise.
anchor:GAMMADIST
Test Cases:
Expression Result Comment
=GAMMADIST(0;3;4) 0
=GAMMADIST(0.5;3;4) 0.001724
=GAMMADIST(9;4;3) 0.066698
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 341 of 442
=GAMMADIST(0;3;4;FALSE()) 0
=GAMMADIST(0.5;3;4;FALSE()) 0.000296
=GAMMADIST(9;4;3;FALSE()) 0.390661
=GAMMADIST(0;3;4;TRUE()) =GAMMADIST(0;3;4)
=GAMMADIST(0.5;3;4;TRUE()) =GAMMADIST(0.5;3;4)
=GAMMADIST(9;4;3;TRUE()) =GAMMADIST(9;4;3)
=GAMMADIST(-1;4;3;TRUE()) 0
=GAMMADIST(-1;3;4;FALSE()) 0
See also GAMMAINV
Note: Ooo2, Gnumeric, Excel and KSpread require the last argument. They also have an additional
constraint
0x
.
6.18.32 GAMMAINV
Summary: returns the inverse of GAMMADIST(x;o;|;TRUE()).
Syntax: GAMMAINV( Number p ; Number o ; Number | )
Returns: Number
Constraints:
0p1
, o > 0, | > 0
Semantics: GAMMAINV returns the unique number
x0
such that GAMMAINV(x;o;|) = p.
anchor:GAMMAINV
Test Cases:
Expression Result Comment
=GAMMADIST(GAMMAINV(0.1;3;4);3;4) 0.1
=GAMMADIST(GAMMAINV(0.3;3;4);3;4) 0.3
=GAMMADIST(GAMMAINV(0.5;4;3);4;3) 0.5
=GAMMADIST(GAMMAINV(0.7;4;3);4;3) 0.7
=GAMMADIST(GAMMAINV(0;3;4);3;4) 0
See also GAMMADIST
6.18.33 GAUSS
Summary: Returns 0.5 less than the standard normal cumulative distribution
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 342 of 442
Syntax: GAUSS( Number x )
Returns: Number
Semantics: Returns NORMDIST(x;0;1;TRUE())-0.5
anchor:GAUSS
Test Cases:
Expression Result Comment
=GAUSS(0) 0 Mean of one value.
=GAUSS(1) 0.341344746 Multiple equivalent values.
See also NORMDIST
6.18.34 GEOMEAN
Summary: returns the geometric mean of a sequence
Syntax: GEOMEAN( { NumberSequenceList N }
+
)
Returns: Number
Semantics: Returns the geometric mean of a given sequence. That means
(
aN
a
)
1/ n
where n is a result of calling COUNT(N).
anchor:GEOMEAN
Test Cases:
Expression Result Comment
=GEOMEAN(7) 7 Mean of one value.
=GEOMEAN(5;5;5;5) 5 Multiple equivalent values.
=GEOMEAN(2;8;2;8) 4 Some values.
=GEOMEAN(8;0;8;8;8;8) Error Error if there is a 0 in the range.
=GEOMEAN([.C11]) 5 One value, range.
=GEOMEAN([.C11:C17]) 3.4451109418 Some values, range.
=GEOMEAN([.B14:.B17]) 2.2133638394 Some values, range.
6.18.35 GROWTH
Summary: Calculates a sequence of values based on a least squares exponential fit to known
value pairs.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 343 of 442
Syntax: GROWTH( NumberSequence knownY [ ; [ NumberSequence knownX ] [ ; [
NumberSequence newX ] [ ; Logical allowConstant = TRUE() ] ] ] )
Returns: Array
Constraints: COUNT(knownY) = COUNT(knownX); COUNT(knownY), COUNT(knownX)>1.
COLUMNS(knownY) = COLUMNS(knownX), ROWS(knownY) = ROWS(knownX)
Semantics: Calculates a sequence of values based on an exponential least squares fit of known
value pairs.
If knownX is omitted or an empty parameter (two consecutive ;; semicolons), it is set to the
sequence
1,2,3, ., n
, where
n=COUNT ( knownY )
.
If newX is omitted or an empty parameter (two consecutive ;; semicolons), it is set to be equal to
knownX.
If allowConstant is TRUE, the fit is to the function
y=bm
x
, where b and m are constants
determined in the fit. If allowConstant is FALSE, the fit is to the function
y=m
x
, i.e when
allowConstant is FALSE, the constant b is set to 1. The default is TRUE.
anchor:GROWTH
Test Cases:
Expression Result Comment
=GROWTH( [.A19:.A23];
[.C19:.C23]; 1 )
2.51984210
=GROWTH( [.A19:.A23];
[.C19:.C23]; 1; FALSE() )
1.48599429
See also TREND
6.18.36 HARMEAN
Summary: returns the harmonic mean of a sequence
Syntax: HARMEAN( { NumberSequenceList N }
+
)
Returns: Number
Semantics: Returns the harmonic mean of a given sequence. That means
n
i=1
n
1
a
i
where a1,a2,...,an are the numbers of the sequence N and n is a result of calling COUNT(N).
anchor:HARMEAN
Test Cases:
Expression Result Comment
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 344 of 442
=HARMEAN(7) 7 Mean of one value.
=HARMEAN(4;4;4;4) 4 Multiple equivalent values.
=HARMEAN(2;4;4) 3 Some values.
=HARMEAN(8;0;8;8;8;8) Error Error if there is a 0 in the range.
=HARMEAN([.C11]) 5 One value, range.
=HARMEAN([.C11:C17]) 2.7184466019 Some values, range.
=HARMEAN([.B14:.B17]) 1.92 Some values, range.
6.18.37 HYPGEOMDIST
Summary: The hypergeometric distribution returns the number of successes in a sequence of n
draws from a finite population without replacement.
Syntax: HYPGEOMDIST( Integer x ; Integer n ; Integer M ; Integer N [ ; Logical Cumulative =
FALSE() ] )
Returns: Number
Constraints: 0 <= x <= n <= N, 0 <= M <= N
Semantics:
x is the number of successes in n trials
n is the number of trials
M is the number of successes in the population
N is the total population
cumulative is a Logical parameter. If cumulative is FALSE(), return the probability of exactly x
successes. If cumulative is TRUE(), return the probability of at most x successes. If omitted,
FALSE() is assumed.
If Cumulative is FALSE(), HYPGEOMDIST returns
(
M
x
)(
NM
nx
)
(
N
n
)
If Cumulative is TRUE(), HYPGEOMDIST returns
i=0
x
(
M
i
)(
NM
ni
)
(
N
n
)
Note:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 345 of 442
(
x
y
)
=0 for y>x
anchor:HYPGEOMDIST
Test Cases:
Expression Result Comment
=HYPGEOMDIST(2;3;3;6;FALSE()) 0.45
If an urn contains 3 red balls
and 3 green balls, the
probability that 2 red balls
will be selected after 3
selections without
replacement. (0.45=27/60).
=HYPGEOMDIST(2;3;3;6) 0.45
The default for cumulative is
FALSE().
=HYPGEOMDIST(0;3;3;6) 0.05
There is a small (5%)
chance of selecting only
green balls.
=HYPGEOMDIST(2;3;3;6;TRUE()) 0.95
The probability of selecting
at most two red balls (i.e 0,
1 or 2).
=HYPGEOMDIST(4;3;3;6) Error X must be <= M
=HYPGEOMDIST(2.8;3;3;6) 0.45 Non-integers are truncated.
=HYPGEOMDIST(-2;3;3;6) Error Values must be >= 0.
=HYPGEOMDIST(0;0;0;0) 1
Note: OOo 2.1 and Kspread 1.6.1 do not include the cumulative parameter. Gnumeric 1.6.3 does
include the cumulative parameter.
6.18.38 INTERCEPT
Summary: Returns the y-intercept of the linear regression line for the given data.
Syntax: INTERCEPT( ForceArray Array Data_Y ; ForceArray Array Data_X )
Returns: Number
Constraints: COLUMNS(Data_X) = COLUMNS(Data_Y), ROWS(Data_X) = ROWS(Data_Y)
Semantics:
INTERCEPT returns the intercept (a) calculated as described in 5.18.41 for the function call
LINEST(DATA_Y,DATA_X,FALSE()).
For an empty element or an element of type Text or Boolean in Data_Y the element at the
corresponding position of Data_X is ignored, and vice versa.
anchor:INTERCEPT
TODO: Test cases.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 346 of 442
6.18.39 KURT
Summary: Return the kurtosis (peakedness) of a data set.
Syntax: KURT( { NumberSequenceList X }
+
)
Returns: Number
Constraints: #Numbers>=4, STDEV(X) <> 0
Note: If there are fewer than four data points, or if the standard deviation of the sample equals zero,
KURT typically returns a #DIV/0! or similar Error value.
Semantics:
Kurtosis characterizes the relative peakedness or flatness of a distribution compared with the
normal distribution. Positive kurtosis indicates a relatively peaked distribution (compared to the
normal distribution), while negative kurtosis indicates a relatively flat distribution.
kurtosis=
(
n(n+1)
(n1)(n2)(n3)
i=1
n
(
x
i
x
s
)
4
)
3(n1)
2
(n2)(n3)
where s is the sample standard deviation, and n is the number of numbers.
anchor:KURT
Test Cases:
Expression Result Comment
=KURT([.C20:.C25]) -0.446162998
=KURT([.C20:.C23];4;4) -0.446162998
6.18.40 LARGE
Summary: Finds the nth largest value in a list.
Syntax: LARGE( NumberSequenceList List ; Number|Array N )
Returns: Number or Array
Constraints: ROUNDUP(N;0)=N. If the resulting N is <1 or larger than the size of List, Error is
returned
Semantics: If N is an array of numbers, an array of largest values is returned.
anchor:LARGE
Test Cases:
Expression Result Comment
=LARGE([.B14:B16];1) 3
=LARGE([.B14:B16];3) 1
=LARGE([.B14:B16];4) Error N is greater than the length of the list
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 347 of 442
=LARGE([.B14:B16];{1;3}) {3;1}
See also SMALL, ROUNDUP
6.18.41 LINEST
Summary: Returns the parameters of a linear trend best fitting the given data. This function shall be
entered as an array formula.
Syntax: LINEST( Array knownY [ ; [ Array knownX ] [ ; Logical Const = TRUE() [ ; Logical Stats =
FALSE() ] ] ] )
Returns: Array
Constraints: COLUMNS(knownY) = COLUMNS(knownX), ROWS(knownY) = ROWS(knownX),
COUNT(knownY) = COUNT(knownX)
Semantics:
knownY: The set of y-values for the equation, either one single column or one single row
knownX: The set of x-values for the equation, a single column or single row matching knownY. If
omitted or an empt y parameter (two consecutive ;; semicolons), it is set to the sequence
1,2,3, ., n
, where
n=COUNT (knownY )
. If one single value, it is applied to all.
Const: If set to FALSE(), the constant a is equal to 0 and the line goes through the zero point.
Stats: If FALSE(), only the regression coefficient is to be calculated. If set to TRUE(), the result will
include other statistical data returned as an array, as shown in the table:
Table 30 - LINEST
slope (bn) slope (bn-1) ... slope (b1) intercept (a)
a Standard error for
the slope (bn)
a Standard error for
the slope (bn-1)
a Standard error
for the slope (b1)
b Standard error for the
intercept (a)
r
2
y Standard error for
the y-Values
F Statistics degrees of freedom
(df)
SSreg Regression
sum of squares
SSresid Residual sum
of squares
Every linear equation can be written using the form
y=a+bx
or
y=a+b
1
x
1
+b
2
x
2
+.+b
n
x
n
if there are multiple x-values.
where y is the dependent y-value
a is the intercept (or constant) that represents the point at which the line crosses the y-axis.
b is the slope coefficient that corresponds to each x-value
a or the INTERCEPT is calculated using this formula :
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 348 of 442
a=
(
i=1
N
( x
i
2
)
) (
i=1
N
( y
i
)
)
(
i=1
N
( x
i
)
) (
I =1
N
( x
i
y
i
)
)
N
(
i=1
N
( x
i
2
)
)
(
i =1
N
( x
i
)
)
2
b or the SLOPE is calculated using this formula:
b=
N
(
i=1
N
( x
i
y
i
)
)
(
i=1
N
( x
i
)
) (
i=1
N
( y
i
)
)
N
(
i=1
N
( x
i
2
)
)
(
i=1
N
( x
i
)
)
2
Standard Error of the Y value is calculated using this formula:
c
y
=
.
1
( N2)
i=1
N
( y
i
abx
i
)
2
Standard Error of the Slope (a) value is calculated using this formula:
c
a
=
.
c
y
2
(
i=1
N
( x
i
2
)
)
N
(
i =1
N
( x
i
2
)
)
(
i=1
N
( x
i
)
)
2
Standard Error of the Intercept (b) value is calculated using this formula:
c
b
=
.
N c
y
2
N
(
i =1
N
( x
i
2
)
)
(
i=1
N
( x
i
)
)
2
The RSQ Value (r
2
) is calculated using the following formula:
r
2
=
i=1
N
( y
i
y)
2
i=1
N
( y
i
y
calc
)
2
i=1
N
( y
i
y)
2
with
y
calc
=a+bx
The Regression Sum of squares is calculated as follows:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 349 of 442
ss
reg
=
i=1
N
( y
i
y)
2
with
y
i
=a+bx
The Residual sum of squares is calculated using this formula:
ss
resid
=
i =1
N
( y
i
y
i
)
2
with
y
i
=a+bx
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 350 of 442
The degrees of freedom (df) is calculated with this formula:
df =nk1
where
n=number of data points
k=number of variables of the regression analysis (columns in knownX )
The F Statistics is calculated as follows:
F=
(
i =1
N
( y
i
y)
2
)
v1
(
i =1
N
( y
i
y
i
)
2
)
v2
y
i
=a+bx
i
v1=1
v2=degrees of freedom ( df )
calculated above
For const = FALSE() the Calculations for the INTERCEPT, the SLOPE and the other statistics are
based on the following formulas:
a or the INTERCEPT is zero by definition:
a=0
bydefinitionastheregressionlinegoesthroughthePoint (00)
b or the SLOPE is calculated using this formula:
b=
i=1
n
xy
i =1
n
x
2
Standard Error of the Y value is calculated using this formula:
c
y
=
.
(
ss
resid
df
)
Standard Error of the Slope (a) value is calculated using this formula:
c
a
=#N/A
as a=0 by definition, nothing calculated no error value possible
Standard Error of the Intercept (b) value is calculated using this formula:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 351 of 442
c
b
=
c
y
.
i=1
N
( x
i
2
)
The RSQ Value (r
2
) is calculated using the following formula:
r
2
=
(
i=1
n
xy
( .
i =1
N
( x
i
2
)
.
i =1
N
( y
i
2
)
)
)
2
The Regression Sum of squares is calculated as follows:
ss
reg
=ss
total
ss
resid
with
ss
total
=
i =1
N
( y
i
2
)
The Residual sum of squares is calculated using this formula:
ss
resid
=
i =1
N
( y
i
y
i
)
2
with
y
i
=bx
The degrees of freedom (df) is calculated with this formula:
df =nk
where
n=number of data points
k=number of variables of the regression analysis (columns in knownX )
The F Statistics is calculated as follows:
F=
(
ss
reg
( N df )
)
(
ss
resid
df
)
anchor:LINEST
Test Cases:
The output of the LINEST function for the following example gives :
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 352 of 442
Expressions Result Result Result Comment
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 353 of 442
{=LINEST([.D5
1:.D57];
[.C51:.C57];1;1
)}
2.4417721518987
300
80.17721518987
34000
82.333333333335600
0
0.4310192568130
110
5.805632138270
3600
9.3460531946624500
0.8652054520596
360
4.578900426294
9500
32.093488396964
7000
5.000000000000
0000
672.88264014466
00000
104.8316455696
260000
{=LINEST([.D5
1:.D57];
[.B51:.C57];1;1
)}
4.1666666666685
200
-
3.476190476194
2100
5.4613541259372
500
10.96442466692
42000
0.8685096742591
380
5.056231421767
9400
13.210244470316
0000
4.000000000000
0000
675.45238095239
60000
102.2619047618
940000
{=LINEST([.D5
1:.D57];
[.C51:.C57];0;1
)}
8.1236220472440
900
0.000000000000
0000
2.6966993125482
900
36.32330562663
00000
0.8652054520596
360
4.578900426294
9500
32.093488396964
7000
5.000000000000
0000
-
3325.8770528684
000000
4103.591338582
6900000
{=LINEST([.D5
1:.D57];
[.C51:.C57];1;0
2.4417721518987
300
80.17721518987
34000
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 354 of 442
)}
{=LINEST([.D5
1:.D57];
[.C51:.C57];0;0
)}
8.1236220472440
900
0.000000000000
0000
6.18.42 LOGEST
Summary: Returns the array of values for an exponential curve that best fits your data.. This
function shall be entered as an array formula.
Syntax: LOGEST( Array knownY [ ; [ Array knownX ] [ ; Logical Const = TRUE() [ ; Logical Stats =
FALSE() ] ] ] )
Returns: Array
Constraints: COLUMNS(knownY) = COLUMNS(knownX), ROWS(knownY) = ROWS(knownX),
COUNT(knownY) = COUNT(knownX)
Semantics:
knownY: The set of y-values for the equation, either one single column or one single row
knownX: The set of x-values for the equation, a single column or single row matching knownY. If
omitted or an empty parameter (two consecutive ;; semicolons), it is set to the sequence
1,2,3, ., n
, where
n=COUNT (knownY )
. If one single value, it is applied to all.
Const: FALSE() to specify whether the constant b is equal to 1.
Stats: TRUE() to specify to return additional regression statistics.
Every exponential equation can be written using the form
y=ab
x
or
y=a
(
b
1
x
1
)
(
b
2
x
2
)
.
(
b
n
x
n
)
if there are multiple x-values.
where 'y' is the dependent y-value
The b-values are bases corresponding to each exponent x-value
a is a constant value.
The Functions used to calculate the LOGEST values are the same as for the LINEST function. You
have just to make the Y-Values the natural logarithmic of the given ones ( C=Y and the New Y=ln
(C)). The result for the 'a' and 'b' values has to be calculated by applying the EXP() function to the
values.
LOGEST with Stats parameter set to TRUE() returns additional statistical data in an array. They are
at the positions shown in the table :
Table 31 - LOGEST
slope (bn) slope (bn-1) ... slope (b1) intercept (a)
a Standard error for
the slope (bn)
a Standard error for
the slope (bn-1)
a Standard error
for the slope (b1)
b Standard error for the
intercept (a)
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 355 of 442
r
2
y Standard error for
the y-Values
F Statistics degrees of freedom
(df)
SSreg Regression
sum of squares
SSresid Residual sum
of squares
anchor:LOGEST
Test Cases:
Expressions Result Result Result Comment
{=LOGEST([.D
51:.D57];
[.C51:.C57];1;1
)}
1.022 84.486
0.003 0.046
0.887 0.036
39.132 5.000
0.051 0.007
{=LOGEST([.D
51:.D57];
[.B51:.C57];1;1
)}
1.034 0.977 85.732
0.043 0.087 0.074
0.889 0.040 #N/A
15.979 4.000 #N/A
0.051 0.006 #N/A
{=LOGEST([.D
51:.D57];
[.C51:.C57];0;1
)}
1.399 1.000
0.147 1.985
0.887 0.036
39.132 5.000
-12.193 12.250
{=LOGEST([.D
51:.D57];
1.022 84.486
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 356 of 442
[.C51:.C57];1;0
)}
{=LOGEST([.D
51:.D57];
[.C51:.C57];0;0
)}
1.399 1.000
TODO: Need to fix this to be in correct format.
6.18.43 LOGINV
Summary: returns the inverse of LOGNORMDIST(x;Mean;StandardDeviation,TRUE()).
Syntax: LOGINV( Number p [ ; Number Mean = 0 [ ; Number StandardDeviation = 1 ] ] )
Returns: Number
Constraints: StandardDeviation > 0 and 0 < p < 1.
Semantics: LOGINV returns the unique number x such that
LOGNORMDIST(x;Mean;StandardDeviation;TRUE()) = p.
anchor:LOGINV
Test Cases:
Expression Result Comment
=LOGNORMDIST(LOGINV(0.1;0;1);0;1
;TRUE())
0.1
=LOGNORMDIST(LOGINV(0.3;0;1);0;1
;TRUE())
0.3
=LOGNORMDIST(LOGINV(0.5;0;1);0;1
;TRUE())
0.5
=LOGNORMDIST(LOGINV(0.7;0;1);0;1
;TRUE())
0.7
=LOGNORMDIST(LOGINV(0.9;0;1);0;1
;TRUE())
0.9
=LOGNORMDIST(LOGINV(0.1;1;4);1;4
;TRUE())
0.1
=LOGNORMDIST(LOGINV(0.3;1;4);1;4
;TRUE())
0.3
=LOGNORMDIST(LOGINV(0.5;1;4);1;4
;TRUE())
0.5
=LOGNORMDIST(LOGINV(0.7;1;4);1;4
;TRUE())
0.7
=LOGNORMDIST(LOGINV(0.9;1;4);1;4
;TRUE())
0.9
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 357 of 442
=LOGINV(0.5) 1
See also LOGNORMDIST
6.18.44 LOGNORMDIST
Summary: returns the value of the probability density function or the cumulative distribution function
for the lognormal distribution with the mean and standard deviation given.
Syntax: LOGNORMDIST( Number x [ ; Number = 0 [ ; Number o = 1 [ ; Logical Cumulative =
TRUE() ] ] ] )
Returns: Number
Constraints: o > 0; x > 0 if Cumulative is FALSE()
Semantics: If Cumulative is FALSE(), LOGNORMDIST returns the value
e
1
2
(
ln( x)j
c
)
2
x .2nc
If Cumulative is TRUE(), LOGNORMDIST returns the value
0
x
e
1
2
(
ln( t)j
c
)
2
t .2nc
dt
if X > 0 and 0 otherwise.
anchor:LOGNORMDIST
Test Cases:
Expression Result Comment
=LOGNORMDIST(1) 0.5
=LOGNORMDIST(1;1;4) 0.401294
=LOGNORMDIST(1;0;1;FALSE()) 0.398942
=LOGNORMDIST(1;0;1;TRUE()) 0.5
=LOGNORMDIST(1;1;4;FALSE()) 0.096667
=LOGNORMDIST(1;1;4;TRUE()) 0.401294
=LOGNORMDIST(1;-1;4;FALSE()) 0.096667
=LOGNORMDIST(1;-1;4;TRUE()) 0.598706
=LOGNORMDIST(2;-1;4;FALSE()) 0.045595
=LOGNORMDIST(2;-1;4;TRUE()) 0.663957
=LOGNORMDIST(3;0;1;TRUE()) 0.864031
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 358 of 442
=LOGNORMDIST(100;0;1;TRUE()) 0.999998
=LOGNORMDIST(-1;0;1;FALSE()) Error constraint failure
=LOGNORMDIST(-1;0;1;TRUE()) 0
=LOGNORMDIST(1;0;-1;FALSE()) Error constraint failure
Note: In Ooo2, Gnumeric and KSpread the second and third arguments are required and the last is
not allowed.
6.18.45 MAX
Summary: Return the maximum from a set of numbers.
Syntax: MAX( { NumberSequenceList N }
+
)
Returns: Number
Constraints: None.
Semantics: Returns the value of the maximum number in the list passed in. Non-numbers are
ignored. Note that if Logical types are a distinct type, they are not included. What happens when
MAX is provided 0 parameters is implementation-defined, but MAX with no parameters should
return 0.
anchor:MAX
Test Cases:
Expression Result Comment
=MAX(2;4;1;-8) 4 Negative numbers are smaller than positive numbers.
=MAX([.B4:.B5]) 3 The maximum of (2,3) is 3.
=ISNA(MAX(NA())) True Inline errors are propagated.
=MAX([.B3:.B5]) 3 Strings are not converted to numbers and are ignored.
=MAX(-1;[.B7]) -1 Strings are not converted to numbers and are ignored.
=MAX([.B3:.B9]) Error Errors inside ranges are NOT ignored.
See also MAXA, MIN
Note: There was debate on whether or not we should we mandate support for zero parameters.
Excel 2002 and OOo dont support it. Gnumeric does. The compromise above gives a
recommendation without mandating it.
6.18.46 MAXA
Summary: Return the maximum from a set of values, including values of type Text and Logical.
Syntax: MAXA( { Any N }
+
)
Returns: Number
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 359 of 442
Constraints: None.
Semantics: A variation of the MAX function that includes values of type Text and Logical. Text
values are treated as number 0. Logical True is treated as 1, and False is treated as 0. Empty cells
are not included. What happens when MAXA is provided 0 parameters is implementation-defined.
Any N may be of type ReferenceList.
anchor:MAXA
Test Cases:
Expression Result Comment
=MAXA(2;4;1;-8) 4 Negative numbers are smaller than positive numbers.
=MAXA([.B4:.B5]) 3 The maximum of (2,3) is 3.
=ISNA(MAXA(NA())
)
True Inline errors are propagated.
=MAXA([.B3:.B5]) 3 Cell text is converted to 0.
=MAXA(-1;[.B7]) 0 Cell text is converted to 0.
=MAXA("a") Error Text inline is NOT ignored.
=MAXA([.B3:.B9]) Error Errors inside ranges are NOT ignored.
=MAXA([.B6:.B7] 1 Logicals are considered numbers.
See also MAX, MIN, MINA
Note: There was debate on whether or not we should we mandate support for zero parameters; see
the text for MAX.
6.18.47 MEDIAN
Summary: Returns the median (middle) value in the list.
Syntax: MEDIAN( { NumberSequenceList X}+ )
Returns: Number
Semantics:
MEDIAN logically ranks the numbers (lowest to highest). If given an odd number of values, MEDIAN
returns the middle value. If given an even number of values, MEDIAN returns the arithmetic average
of the two middle values.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 360 of 442
n=is thecount of the ranked numbersequence
x=x
(
( n+1)
2
)
for n=odd
x=
1
2 (
x
(
n
2
)
+x
(
n
2
+1)
)
for n=even
anchor:MEDIAN
Test Cases:
Expression Result Comment
=MEDIAN([.E51:.E52]) 8.850000000
=MEDIAN([.E52;.E54];45) 7.200000000
=MEDIAN([.E52:.E55]) 7.650000000
=MEDIAN(1;3;13;14;15) 13.000000000
=MEDIAN(1;3;13;14;15;35) 13.500000000
6.18.48 MIN
Summary: Return the minimum from a set of numbers.
Syntax: MIN( { NumberSequenceList N }
+
)
Returns: Number
Constraints: None.
Semantics: Returns the value of the minimum number in the list passed in. Returns zero if no
numbers are provided in the list. What happens when MIN is provided 0 parameters is
implementation-defined, but MIN() with no parameters should return 0.
anchor:MIN
Test Cases:
Expression Result Comment
=MIN(2;4;1;-8) -8 Negative numbers are smaller than positive numbers.
=MIN([.B4:.B5]) 2 The minimum of (2,3) is 2.
=MIN([.B3]) 0 If no numbers are provided in all ranges, MIN returns 0
=MIN("a") Error Non-numbers inline are NOT ignored.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 361 of 442
=MIN([.B3:.B5]) 2 Cell text is not converted to numbers and is ignored.
Note: There was debate on whether or not we should we mandate support for zero parameters; see
the discussion for MAX.
See also MAX, MINA
6.18.49 MINA
Summary: Return the minimum from a set of values, including values of type Text and Logical.
Syntax: MINA( { Any N }
+
)
Returns: Number
Constraints: None.
Semantics: A variation of the MIN function that includes values of type Text and Logical. Text
values are treated as number 0. Logical True is treated as 1, and False is treated as 0. Empty cells
are not included. What happens when MINA is provided 0 parameters is implementation-defined.
Any N may be of type ReferenceList.
anchor:MINA
Test Cases:
Expression Result Comment
=MINA(2;4;1;-8) -8 Negative numbers are smaller than positive numbers.
=MINA([.B4:.B5]
)
2 The minimum of (2,3) is 2.
=MINA(1;[.B7]) 0 Cell text is converted to 0.
=MINA("a") Error Cell text inline is NOT ignored.
=MINA([.B3:.B5]
)
0 Cell text is converted to 0.
=MINA([.B6:.C6] 1 The value True is considered equivalent to 1.
Note: OOo2 has a bug that for MINA (and MAXA) formulas within an area reference returning text
are not considered cell text to be converted to 0, hence the =MINA([.B3:.B5]) test case fails.
Note: There was debate on whether or not we should we mandate support for zero parameters; see
the discussion for MAX.
See also MIN, MAXA
6.18.50 MODE
Summary: Returns the most common value in a data set.
Syntax: MODE( { ForceArray NumberSequence N }+ )
Semantics: Returns the most common value in a data set. If there are more than one values with
the same largest frequency, returns the smallest value. If the number sequence does no contain at
least two equal values, the MODE is not defined as no most common value can be found. Therefore
an Error message has to be shown.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 362 of 442
anchor:MODE
Test Cases:
Expression Result Comment
=MODE([.F51:.F60]) 4
=MODE([.G51];[.G52];[.G53];[.G54];[.G55];
[.G56];[.G57];[.G58];[.G59];[.G60])
24
=MODE(1;2;3;4;5;6;7;8;9;10) Error
6.18.51 NEGBINOMDIST
Summary: Returns the negative binomial distribution.
Syntax: NEGBINOMDIST( Integer x ; Integer r ; Number p )
x The number of failures.
r The threshold number of successes.
p The probability of a success.
Returns: Number
Constraints:
If (x + r - 1) <= 0 NEGBINOMDIST returns an Error.
If p < 0 or p > 1 NEGBINOMDIST returns an Error.
Semantics:
NEGBINOMDIST returns the probability that there will be x failures before the r-th success, when
the constant probability of a success is p.
Note: This function is similar to the binomial distribution, except that the number of successes is
fixed, and the number of trials is variable. Like the binomial, trials are assumed to be independent.
P
r , p
( x)=
(
x+r1
r1
)
p
r
(1p)
x
(
x+r1
r1
)
is a binomial coefficient
anchor:NEGBINOMDIST
Test Cases:
Expression Result Comment
=NEGBINOMDIST([.F20];[.I29];[.H6]) 0.000130947
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 363 of 442
6.18.52 NORMDIST
Summary: returns the value of the probability density function or the cumulative distribution function
for the normal distribution with the mean and standard deviation given.
Syntax: NORMDIST( Number x ; Number Mean ; Number StandardDeviation [ ; Logical Cumulative
= TRUE() ] )
Returns: Number
Constraints: StandardDeviation > 0.
Semantics: In the following
j
is Mean and
c
is StandardDeviation.
If Cumulative is FALSE(), NORMDIST returns the value
e
1
2
(
xj
c
)
2
.2nc
If Cumulative is TRUE(), NORMDIST returns the value
x
e
1
2
(
tj
c
)
2
.2nc
dt
anchor:NORMDIST
Test Cases:
Expression Result Comment
=NORMDIST(0;1;4;TRUE()) 0.401293
=NORMDIST(0;0;1;FALSE()) 0.398942
=NORMDIST(0;0;1;TRUE()) 0.5
=NORMDIST(0;1;4;FALSE()) 0.096667
=NORMDIST(0;1;4;TRUE()) 0.401293
=NORMDIST(0;-1;4;FALSE()) 0.096667
=NORMDIST(0;-1;4;TRUE()) 0.598706
=NORMDIST(1;-1;4;FALSE()) 0.088016
=NORMDIST(1;-1;4;TRUE()) 0.691462
=NORMDIST(1.281552;0;1;TR
UE())
0.9
=NORMDIST(0;-
1.281552;1;TRUE())
0.9
=NORMDIST(0;0;-1;FALSE()) Error constraint failure
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 364 of 442
See also LEGACY.NORMSDIST
6.18.53 NORMINV
Summary: returns the inverse of NORMDIST(x;Mean;StandardDeviation,TRUE()).
Syntax: NORMINV( Number p ; Number Mean ; Number StandardDeviation )
Returns: Number
Constraints: StandardDeviation > 0 and 0 < p < 1.
Semantics: NORMINV returns the unique number x such that
NORMDIST(x;Mean;StandardDeviation;TRUE()) = p.
anchor:NORMINV
Test Cases:
Expression Result Comment
=NORMDIST(NORMINV(0.1;0;1);0;1;T
RUE())
0.1
=NORMDIST(NORMINV(0.3;0;1);0;1;T
RUE())
0.3
=NORMDIST(NORMINV(0.5;0;1);0;1;T
RUE())
0.5
=NORMDIST(NORMINV(0.7;0;1);0;1;T
RUE())
0.7
=NORMDIST(NORMINV(0.9;0;1);0;1;T
RUE())
0.9
=NORMDIST(NORMINV(0.1;1;4);1;4;T
RUE())
0.1
=NORMDIST(NORMINV(0.3;1;4);1;4;T
RUE())
0.3
=NORMDIST(NORMINV(0.5;1;4);1;4;T
RUE())
0.5
=NORMDIST(NORMINV(0.7;1;4);1;4;T
RUE())
0.7
=NORMDIST(NORMINV(0.9;1;4);1;4;T
RUE())
0.9
See also NORMDIST
6.18.54 LEGACY.NORMSDIST
Summary: returns the value of the cumulative distribution function for the standard normal
distribution.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 365 of 442
Syntax: LEGACY.NORMSDIST( Number x )
Returns: Number
Constraints: None
Semantics: LEGACY.NORMSDIST returns the value
x
e
1
2
t
2
.2n
dt
This is exactly NORMDIST(x;0;1;TRUE()).
anchor:LEGACY.NORMSDIST
Test Cases:
Expression Result Comment
=LEGACY.NORMSDIST(-4) =NORMDIST(-4;0;1;TRUE())
=LEGACY.NORMSDIST(-3) =NORMDIST(-3;0;1;TRUE())
=LEGACY.NORMSDIST(-2) =NORMDIST(-2;0;1;TRUE())
=LEGACY.NORMSDIST(-1) =NORMDIST(-1;0;1;TRUE())
=LEGACY.NORMSDIST(0) =NORMDIST(0;0;1;TRUE())
=LEGACY.NORMSDIST(1) =NORMDIST(1;0;1;TRUE())
=LEGACY.NORMSDIST(2) =NORMDIST(2;0;1;TRUE())
=LEGACY.NORMSDIST(3) =NORMDIST(3;0;1;TRUE())
=LEGACY.NORMSDIST(4) =NORMDIST(4;0;1;TRUE())
See also NORMDIST, LEGACY.NORMSINV
6.18.55 LEGACY.NORMSINV
Summary: returns the inverse of LEGACY.NORMSDIST(x).
Syntax: LEGACY.NORMSINV( Number p )
Returns: Number
Constraints: 0 < p < 1.
Semantics: LEGACY.NORMSINV returns NORMINV (p).
anchor:LEGACY.NORMSINV
Test Cases:
Expression Result Comment
=LEGACY.NORMSINV(0.1) =NORMINV(0.1;0;1)
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 366 of 442
=LEGACY.NORMSINV(0.3) =NORMINV(0.3;0;1)
=LEGACY.NORMSINV(0.5) =NORMINV(0.5;0;1)
=LEGACY.NORMSINV(0.7) =NORMINV(0.7;0;1)
=LEGACY.NORMSINV(0.9) =NORMINV(0.9;0;1)
See also NORMINV, LEGACY.NORMSDIST
6.18.56 PEARSON
Summary: PEARSON returns the Pearson correlation coefficient of two data sets
Syntax: PEARSON( ForceArray Array independent_Values ; ForceArray Array dependent_Values )
Returns: Number
Constraints: COLUMNS(independent_Values) = COLUMNS(dependent_Values),
ROWS(independent_Values) = ROWS(dependent_Values), both sequences shall contain at least
one number at corresponding positions each.
Semantics:
independent_Values represents the array of the first data set. (X-Values)
dependent_Values represents the array of the second data set. (Y-Values)
r=
i =1
N
( x
i
x)( y
i
y)
.
i=1
N
( x
i
x)
2
i=1
N
( y
i
y)
2
x , y arethe averages of the given x , y data
For an empty element or an element of type Text or Boolean in independent_Values the element at
the corresponding position of dependent_Values is ignored, and vice versa.
anchor:PEARSON
Test Cases:
Expression Result Comment
=PEARSON([.A19:.A31];[.C19:.C31]) 0.045989147
=PEARSON([.C51:.C57];[.D51:.D57]) 0.930164207
=PEARSON([.C51:.C57];[.D51:.D56]) Error
6.18.57 PERCENTILE
Summary: Calculates the x-th sample percentile among the values in range.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 367 of 442
Syntax: PERCENTILE( NumberSequenceList Data ; Number x )
Returns: Number
Constraints:
COUNT(Data) > 0
0 <= x <= 1
Semantics:
Data The array or range of values to get the percentile from.
x The percentile value between 0 and 1, inclusive. If x is not a multiple of
1
n1
,
PERCENTILE interpolates to obtain the value between two data points.
Returns the x -th sample percentile of data values in Data . A percentile returns the scale value for a
data series which goes from the smallest (Alpha=0) to the largest value (Alpha=1) of a data series.
For Alpha = 25%, the percentile means the first quartile; Alpha = 50% is the MEDIAN.
Step 1:
Sort the list of numbers given by array Data.
Step 2:
Calculate the ranking 1, ., n, split into integer and decimal part
r=1+x( n1) =I +D
with
x = the percentile you want to find
n = the count of values
I = the integer part of the ranking = r
D = the decimal part of the ranking = rr
Step 3:
Interpolate between the necessary two numbers
PERCENTILE=Y
I
+D
(
Y
I +1
Y
I
)
with Y
I
being the data point ranked at position I
anchor:PERCENTILE
Test Cases:
Expression Result Comment
=PERCENTILE([.A19:.A31];0.38) 24.960000000
=PERCENTILE([.A19:.A31];0.95) 2867.200000000
=PERCENTILE([.A19:.A31];0.05) 1.600000000
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 368 of 442
See also MAX, MEDIAN, MIN, PERCENTRANK, QUARTILE, RANK
6.18.58 PERCENTRANK
Summary: Returns the percentage rank of a value in a sample.
Syntax: PERCENTRANK( NumberSequenceList Data ; Number X [ ; Integer Significance = 3 ] )
Returns: Number
Constraints:
COUNT(Data) > 0
MIN(Data) <= X <= MAX(Data)
INT(Significance) = Significance; Significance >= 1
Semantics:
Data is the array or range of data with numeric values.
X is the value whose rank is to be determined.
Significance is an optional value that identifies the number of significant digits for the
returned percentage value. If omitted, a value of 3 is used (0.xxx).
Returns the rank of a value in a data set Data as a percentage of the data set, a value between 0
and 1, inclusive. This function can be used to evaluate the relative standing of a value within a data
set.
For COUNT(Data) > 1, PERCENTRANK returns r / (COUNT(Data) -1), where r is the rank of X in
Data. The rank of the lowest number in Data is 0, and of the next lowest number 1, and so on. If X
is not in Data, it is assigned a fractional rank proportionately between the rank of the numbers on
either side. Specifically, if X lies between Y and Z=Y+1 (Y < X < Z) with Y being the largest number
smaller than X and Z the smallest number larger than X, and where Y has rank ry, the rank of X is
calculated as
rx=ry+
X Y
ZY
In the special case where COUNT(Data) == 1, the only valid value for X is the single value in Data,
in which case PERCENTRANK returns 1.
anchor:PERCENTRANK
Test Cases:
Expression Result Comment
=PERCENTRANK([.A19:.A31];16;5) 0,33333
=PERCENTRANK([.A19:.A31];4096) 1
=PERCENTRANK([.A19:.A31];128;9) 0,583333333
See also PERCENTILE, RANK
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 369 of 442
6.18.59 PERMUT
Note: This function really belongs in the Mathematics section!!
Summary: returns the number of permutations of k objects taken from n objects.
Syntax: PERMUT( Integer n ; Integer k )
Returns: Number
Constraints: n >= 0; k >= 0; n >= k
Semantics: PERMUT returns
(
n
k
)
k !
respectively
n!
( nk) !
anchor:PERMUT
Test Cases:
Expression Result Comment
=PERMUT(2;2) 4
=PERMUT(4;2) 12
=PERMUT(4.3;2.1) =PERMUT(4;2)
=PERMUT(-4;2) Error
=PERMUT(4;-2) Error
6.18.60 PERMUTATIONA
Summary: Returns the number of permutations for a given number of objects (repetition allowed).
Syntax: PERMUTATIONA( Integer Total ; Integer Chosen )
Returns: Number
Constraints: Total >= 0, Chosen >= 0
Semantics: Given Total number of objects, return the number of permutations containing Chosen
number of objects, with repetition permitted. The result is 1 if Total = 0 and Chosen = 0, otherwise
the result is
PERMUTATIONA = Total
Chosen
anchor:PERMUTATIONA
Test Cases:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 370 of 442
Expression Result Comment
=PERMUTATIONA([.A25];[.A20]) 4096
=PERMUTATIONA(6;3) 216
=PERMUTATIONA([.A25];2) 4096
6.18.61 PHI
Summary: Returns the values of the density function for a standard normal distribution.
Syntax: PHI( Number N )
Returns: Number
Semantics: PHI(N) is a synonym for NORMDIST(N,0,1,FALSE()).
anchor:PHI
Test Cases:
Expression Result Comment
=PHI([.C23]/10) 0.381387815
=PHI(-[.C23]/10) 0.381387815
=PHI(0) 0.398942280
OOo function, Returns the values of the distribution function for a standard normal distribution.
6.18.62 POISSON
Summary: returns the probability or the cumulative distribution function for the Poisson distribution
Syntax: POISSON( Integer x ; Number i [ ; Logical Cumulative = TRUE() ] )
Returns: Number
Constraints: i > 0, x >= 0
Semantics: If Cumulative is FALSE(), POISSON returns the value
e
\
\
x
x !
If Cumulative is TRUE(), POISSON returns the value
k=0
k= x
e
\
\
k
k!
anchor:POISSON
Test Cases:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 371 of 442
Expression Result Comment
=POISSON(0,1,FALSE()) 0.367880
=POISSON(0,2,FALSE()) 0.135335
=POISSON(0,1,TRUE()) =POISSON(0,1,FALSE())
=POISSON(1,1,TRUE())
=POISSON(0,1,FALSE()) +
POISSON(1,1,FALSE())
=POISSON(1.5,1,TRUE()) =POISSON(1,1,TRUE())
=POISSON(1.5,1,FALSE()) =POISSON(1,1,FALSE())
=POISSON(1,1) =POISSON(1,1,TRUE())
=POISSON(0,-1,TRUE()) Error
=POISSON(0,1.5,FALSE()) 0.223130
Note: In Ooo2, Gnumeric and KSpread all arguments are required.
6.18.63 PROB
Summary: Returns the probability that a discrete random variable lies between two limits.
Syntax: PROB( ForceArray Array Data ; ForceArray Array Probability ; Number Start [ ; Number
End ] )
Returns: Number
Constraints:
The sum of the probabilities in Probability shall equal 1.
All values in Probability shall be > 0 and <= 1.
COUNT(Data) = COUNT(Probability)
Semantics:
Data is the array or range of data in the sample ( the Number values in this array or
range are refered to below as
d
1,
d
2,
., d
n
).
Probability is the array or range of the corresponding probabilities ( the Number values in this
array or range are refered to below as
p
1,
p
2,
., p
n
).
Start is the start value (lower bound) of the interval whose probabilities are to be
summed.
End (optional) is the end value (upper bound) of the interval whose probabilities are to
be summed. If omitted, End = Start is used.
axb
Suppose that
I ( x , a , b)
denotes the indicator function that is 1 if and 0 otherwise.
Then PROB returns
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 372 of 442
i=1
n
( I ( d
i
, Start , End)p
i
)
i.e. the sum of all probabilities p
i
whose corresponding data value d
i
satisfies Start d
i
End .
Note that if End Start then PROB returns 0 since in this case I (d
i
, Start , End )=0 for all i.
anchor:PROB
Test Cases:
Expression Result Comment
=PROB([.H51:.H54];
[.I51:.I54];2;3)
0.5
=PROB([.H51:.H54];
[.I51:.I54];-1;1)
0.5
=PROB([.H51:.H54];
[.I51:.I54];1;2)
0.4
See also
6.18.64 QUARTILE
Summary: Returns a quartile of a set of data points.
Syntax: QUARTILE( NumberSequence Data ; Integer Quart )
Returns: Number
Constraints:
COUNT(Data) > 0
0 <= Quart <= 4
Semantics:
Data The cell range or data array of numeric values.
Quart The number of the quartile to return.
If Quart = 0, the minimum value is returned, which is equivalent to the MIN() function.
If Quart = 1, the value of the 25th percentile is returned.
If Quart = 2, the value of the 50th percentile is returned, which is equivalent to the MEDIAN()
function.
If Quart = 3, the value of the 75th percentile is returned.
If Quart = 4, the maximum value is returned, which is equivalent to the MAX() function.
Based on the statistical rank of the data points in Data, QUARTILE returns the percentile value
indicated by Quart. The percentile is calculated as Quart divided by 4. An algorithm to calculate the
percentile for a set of data points is given in the definition of PERCENTILE.
anchor:QUARTILE
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 373 of 442
Test Cases:
Expression Result Comment
=QUARTILE ([.A19:.A25];3) 24.000000000
=QUARTILE ([.F19:.F26];1) -22.250000000
=QUARTILE ([.A10:A15];2) Error
=QUARTILE ([.A19:A25];5) Error
=QUARTILE ([.F19:.F26];1.5) -22.250000000
=QUARTILE ({1,2,4,8,16,32,64};3) 24.000000000
See also MAX, MEDIAN, MIN, PERCENTILE, PERCENTRANK, RANK
6.18.65 RANK
Summary: R eturns the rank of a number in a list of numbers.
Syntax: RANK( Number Value ; NumberSequenceList Data [ ; Number Order = 0 ] )
Returns: Number
Constraints: Value shall exist in Data.
Semantics: The RANK function returns the rank of a value within a list.
Value the number for which to determine the rank.
Data numbers used to determine the ranking.
Order specifies how to rank the numbers:
If 0 or omitted, Data is ranked in descending order.
If not 0, Data is ranked in ascending order.
If a number in Data occurs more than once it is given the same rank, but increments the rank for
subsequent different numbers. If Value does not exist in Data an Error is returned.
anchor:RANK
Test Cases:
Expression Result Comment
=RANK([.A20];[.A19:.A25];1) 2
=RANK([.A25];[.A19:.A25];0) 1
=RANK([.A21];[.A19:.A25]) 5
6.18.66 RSQ
Summary: Returns the square of the Pearson product moment correlation coefficient through data
points in known_y's and known_x's.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 374 of 442
Syntax: RSQ( ForceArray Array arrayY ; ForceArray Array arrayX )
Returns: Number
Constraints:
The arguments shall be either numbers or 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 "arrayY" and "arrayX" are empty or have a different number of data points, then #N/A is returned.
COLUMNS(arrayY) = COLUMNS(arrayX), ROWS(arrayY) = ROWS(arrayX)
Semantics: The r-squared value can be interpreted as the proportion of the variance in y
attributable to the variance in x.
r
2
=
i=1
N
( y
i
y)
2
i=1
N
( y
i
y
calc
)
2
i=1
N
( y
i
y)
2
y
calc
=a+bx
and
a=
(
i=1
N
( x
i
2
)
) (
i=1
N
( y
i
)
)
(
i=1
N
( x
i
)
) (
I =1
N
( x
i
y
i
)
)
N
(
i=1
N
( x
i
2
)
)
(
i =1
N
( x
i
)
)
2
b=
N
(
i =1
N
( x
i
y
i
)
)
(
i =1
N
( x
i
)
) (
i=1
N
( y
i
)
)
N
(
i=1
N
( x
i
2
)
)
(
i =1
N
( x
i
)
)
2
The result of the RSQ function is the same as PEARSON * PEARSON.
For an empty element or an element of type Text or Boolean in arrayY the element at the
corresponding position of arrayX is ignored, and vice versa.
anchor:RSQ
Test Cases:
Expression Result Comment
=RSQ ([.H19:.H31];[.I19:.I31]) 0.075215010
=RSQ ([.H19:.H31];[.I19:.I30]) #N/A
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 375 of 442
See also PEARSON
6.18.67 SKEW
Summary: Estimates the skewness of a distribution using a sample set of numbers.
Syntax: SKEW( { NumberSequenceList sample }
+
)
Returns: Number
Constraints: The sequence shall contain three numbers at least.
Semantics: Estimates the skewness of a distribution using a sample set of numbers.
Given the expectation value
x
and the standard deviation estimate
s
, the skewness becomes
v=
N
( N1)( N2)
i=1
N
(
x
i
x
s
)
3
anchor:SKEW
Test Cases:
Expression Result Comment
=SKEW( 1; 2; 4 ) 0.935219
Expectation value: 2.333333
Standard deviation: 1.257525
Third central moment: 0.740741
=SKEW( [.A19:.A23] ) 1.325315
=SKEW( 1; 2 ) Error At least three numbers.
See also SKEWP
6.18.68 SKEWP
Summary: Calculates the skewness of a distribution using the population of a random variable.
Syntax: SKEWP( { NumberSequence population }
+
)
Returns: Number
Constraints: The sequence shall contain three numbers at least.
Semantics: Calculates the skewness of a distribution using the population, i.e. the possible
outcomes, of a random variable.
Given the expectation value
x
and the standard deviation
c
, the skewness becomes
v=
1
N
i=1
N
(
x
i
x
c
)
3
anchor:SKEWP
Test Cases:
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 376 of 442
Expression Result Comment
=SKEWP( 1; 2; 4 ) 0.381802
Expectation value: 2.333333
Standard deviation: 1.247219
Third central moment: 0.740741
=SKEWP( [.A19:.A23] ) 0.889048
=SKEWP( 1; 2 ) Error Three numbers at least.
See also SKEW
6.18.69 SLOPE
Summary: Calculates the slope of the linear regression line.
Syntax: SLOPE( ForceArray Array y ; ForceArray Array x )
Returns: Number
Constraints: COLUMNS(y) = COLUMNS(x), ROWS(y) = ROWS(x), both sequences shall contain
at least one number at corresponding positions each.
Semantics: Calculates the slope of the linear regression line.
a=
i=1
N
( x
i
x)( y
i
y)
i=1
N
( x
i
x)
2
For an empty element or an element of type Text or Boolean in y the element at the corresponding
position of x is ignored, and vice versa.
anchor:SLOPE
Test Cases:
Expression Result Comment
=SLOPE( [.B4:.B5];
[.C4:.C5] )
1
=SLOPE( [.A19:.A24];
[.A26:.A31] )
0.007813
See also INTERCEPT, STEYX
6.18.70 SMALL
Summary: Finds the nth smallest value in a list.
Syntax: SMALL( NumberSequenceList List ; Integer|Array N )
Returns: Number or Array
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 377 of 442
Constraints: ROUNDDOWN(N;0)=N, effectively being INT(N)=N for positive numbers. If the
resulting N is <1 or larger than the size of List, Error is returned.
Semantics: If N is an array of numbers, an array of smallest values is returned.
anchor:SMALL
Test Cases:
Expression Result Comment
=SMALL([.B14:.B16];1) 1
=SMALL([.B14:.B16];3) 3
=SMALL([.B14:.B16];4) Error N is greater than the length of the list
=SMALL([.B14:.B16];{1;3}) {1;3}
See also LARGE, ROUNDDOWN
6.18.71 STANDARDIZE
Summary: Calculates a normalized value of a random variable.
Syntax: STANDARDIZE( Number value ; Number mean ; Number sigma )
Returns: Number
Constraints: sigma > 0
Semantics: Calculates a normalized value of a random variable.
STANDARDIZE=
(valuemean)
sigma
anchor:STANDARDIZE
Test Cases:
Expression Result Comment
=STANDARDIZE( 1; 2.5; 0.1
)
-15
=STANDARDIZE( -1; -2; 2 ) 0.5
=STANDARDIZE( 1; 1; 0 ) Error sigma > 0
See also GAUSS
6.18.72 STDEV
Summary: Compute the sample standard deviation of a set of numbers.
Syntax: STDEV( { NumberSequenceList N }
+
)
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 378 of 442
Returns: Number
Constraints: At least two numbers shall be included. Returns an Error if less than two Numbers are
provided.
Semantics: Computes the sample standard deviation s, where
s
2
=
1
n1
i=1
n
( x
i
x)
2
with
x=
1
n
i=1
n
x
i
Note that s is not the same as the standard deviation of the set, , which uses n rather than n 1.
anchor:STDEV
Note: See "The Art of Computer Programming" by Donald E. Knuth, Volume 2, Third Edition, page
232, for an algorithm better than the naive algorithm.
Test Cases:
Expression Result Comment
=STDEV(2;4)/SQRT(2) 1 The sample standard deviation of (2;4) is SQRT(2).
=STDEV([.B4:.B5])*SQRT(2
)
1 The sample standard deviation of (2;3) is 1/SQRT(2).
=STDEV([.B3:.B5])*SQRT(2
)
1 Strings are not converted to numbers and are ignored.
=STDEV({10000000001;100
00000002;10000000003;10
000000004;10000000005;1
0000000006;10000000007;
10000000008;10000000009
;10000000010})
3.027650
Ensure that implementations use a reasonably stable
way of calculating STDEV.
=STDEV(1) Error At least two numbers must be included
See also STDEVP, AVERAGE
6.18.73 STDEVA
Summary: Calculate the standard deviation using a sample set of values, including values of type
Text and Logical.
Syntax: STDEVA( { Any sample }
+
)
Returns: Number
Constraints: COUNTA(sample) > 1.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 379 of 442
Semantics: Unlike the STDEV function, includes values of type Text and Logical. Text values are
treated as number 0. Logical True is treated as 1, and False is treated as 0. Empty cells are not
included.
The handling of string constants as parameters is implementation-defined. Either, string constants
are converted to numbers, if possible and otherwise, they are treated as zero, or string constants
are always treated as zero.
Suppose the resulting sequence of values is x1, x2, , xn.Then let
x=
1
n
i=1
n
x
i
STDEVA returns
s=
.
1
n1
i=1
n
( x
i
x)
2
anchor:STDEVA
Test Cases:
Expression Result Comment
=STDEVA(2;4)/SQRT(2) 1 The sample standard deviation of (2;4) is SQRT(2).
=STDEVA([.B5:.C6]) 2.581989 Logicals (referenced) are converted to numbers.
=STDEVA( TRUE();
FALSE() )
0.707107 Logicals (inlined) are converted to numbers.
=STDEVA(1) Error At least two numbers must be included
See also STDEV
Note: OOo Calc (2.02): Treats strings as zero in STDEVA, even if they would be convertible.
Ignores them for STDEV. Converts Logicals to {0,1} in both cases, STDEV and STDEVA.
Gnumeric (1.6.1): Converts logicals and strings (if possible) for STDEVA. Ignores both in STDEV.
6.18.74 STDEVP
Summary: Calculates the standard deviation using the population of a random variable, including
values of type Text and Logical.
Syntax: STDEVP( { NumberSequence N }
+
)
Returns: Number
Constraints: None.
Semantics: Computes the standard deviation of the set , where
c
2
=
1
n
i=1
n
( x
i
x)
2
Note that is not the same as the sample standard deviation, s, which uses n 1 rather than n.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 380 of 442
anchor:STDEVP
Test Cases:
Expression Result Comment
=STDEVP(2;4) 1 The standard deviation of the set for (2;4) is 1.
=STDEVP([.B4:.B5])*2 1 The standard deviation of the set for (2;3) is 0.5.
=STDEVP([.B3:.B5])*2 1 Strings are not converted to numbers and are ignored.
=STDEVP(1) 0 STDEVP(1) is 0.
See also STDEV, AVERAGE
6.18.75 STDEVPA
Summary: Calculates the standard deviation using the population of a random variable, including
values of type Text and Logical.
Syntax: STDEVPA( { Any sample }
+
)
Returns: Number
Constraints: None.
Semantics: Unlike the STDEV function, includes values of type Text and Logical. Text values are
treated as number 0. Logical True is treated as 1, and False is treated as 0. Empty cells are not
included.
Given the expectation value
x
the standard deviation becomes
c
2
=
1
n
i=1
n
( x
i
x)
2
In the sequence, only Numbers and Logical types are considered; cells with Text are converted to 0;
other types are ignored. If Logical types are a distinct type, they are still included, with True
considered 1 and False considered 0. Any sample may be of type ReferenceList.
The handling of string constants as parameters is implementation-defined. Either, string constants
are converted to numbers, if possible and otherwise, they are treated as zero, or string constants
are always treated as zero.
anchor:STDEVPA
Test Cases:
Expression Result Comment
=STDEVPA(2;4) 1 The sample standard deviation of (2;4) is 1.
=STDEVPA([.B5:.C6]) 2.236068 Logicals (referenced) are converted to numbers.
=STDEVPA( TRUE();
FALSE() )
0.5 Logicals (inlined) are converted to numbers.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 381 of 442
See also STDEVP
Note:
OOo Calc (2.02): Treats strings as zero in STDEVA, even if they would be convertible. Ignores them
for STDEV. Converts Logicals to {0,1} in both cases, STDEV and STDEVA.
Gnumeric (1.6.1): Converts logicals and strings (if possible) for STDEVA. Ignores both in STDEV.
6.18.76 STEYX
Summary: Calculates the standard error of the predicted y value for each x in the regression.
Syntax: STEYX( ForceArray Array measuredY ; ForceArray Array X )
Returns: Number
Constraints: COLUMNS(measuredY) = COLUMNS(X), ROWS(measuredY) = ROWS(X), both
sequences shall contain at least three numbers at corresponding positions each.
Semantics: Calculates the standard error of the predicted y value for each x in the regression.
STEYX=
.
1
n(n2)
(
n
n
y
i
2
(
n
y
i
)
2
(
n
n
x
i
y
i
n
x
i
n
y
i
)
2
n
n
x
2
n
x
)
2
)
For an empty element or an element of type Text or Boolean in measuredY the element at the
corresponding position of X is ignored, and vice versa.
anchor:STEYX
Test Cases:
Expression Result Comment
=STEYX( [.C19:.C23];
[.A19:.A23] )
2.370953
=STEYX( [.A19:.A23];
[.A25:.A29] )
0
=STEYX( [.B4:.B5];
[.C4:.C5] )
Error at least three number per sequence
See also INTERCEPT, SLOPE
6.18.77 LEGACY.TDIST
Summary: Returns the area ot the tail or tails of the probability density function of the t-distribution.
Syntax: LEGACY.TDIST( Number x ; Integer df ; Integer tails)
Returns: Number
Constraints: x0, df 1, tails = 1 or 2
Semantics: Then LEGACY.TDIST returns
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 382 of 442
tails
f (t )dt
where
f (t )=
I
(
df +1
2
)
.ndf I
(
df
2
)
(
1+
t
2
df
)
( df +1)
2
Note that df denotes the degrees of freedom of the t-distribution and is the Gamma function.
anchor:LEGACY.TDIST
Test Cases:
Expression Result Comment
=LEGACY.TDIST( 0.5; 1; 1 ) 0.352416
=LEGACY.TDIST( -1.5; 2;
2 )
0.272393
=LEGACY.TDIST( 0.5; 5; 1 ) 0,319149
=LEGACY.TDIST( 1; 1; 3 ) Error mode = { 1; 2 }
=LEGACY.TDIST( 1; 0; 1 ) Error degreeOfFreedom >= 1
See also BETADIST, BINOMDIST, CHISQDIST, EXPONDIST, FDIST, GAMMADIST, GAUSS,
HYPGEOMDIST, LOGNORMDIST, NEGBINOMDIST, NORMDIST, POISSON, WEIBULL
6.18.78 TINV
Summary: Calculates the inverse of the two-tailed t-distribution.
Syntax: TINV( Number probability ; Integer degreeOfFreedom )
Returns: Number
Constraints: 0 < probability <= 1, degreeOfFreedom >= 1
Semantics: Calculates the inverse of the two-tailed t-distribution.
anchor:TINV
Test Cases:
Expression Result Comment
=TINV( 1; 2 ) 0 p=1 -> t=0
=TINV( 0.5; 2 ) 0.816497
=TINV( 0.25; 3 ) 1.422625
=TINV( 2; 3 ) Error 0 <= probability <= 1
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 383 of 442
=TINV( 1; 0 ) Error degreeOfFreedom >= 1
See also LEGACY.TDIST
6.18.79 TREND
Summary: Calculates a sequence of values based on a linear regression of known value pairs.
Syntax: TREND( NumberSequence knownY [ ; [ NumberSequence knownX ] [ ; [
NumberSequence newX ] [ ; Logical allowOffset = TRUE() ] ] ] )
Returns: Array
Constraints: COUNT(knownY) = COUNT(knownX), COLUMNS(knownY) = COLUMNS(knownX),
ROWS(knownY) = ROWS(knownX)
Semantics: Calculates a sequence of values based on a linear regression of known value pairs.
If knownX is omitted or an empty parameter (two consecutive ;; semicolons), it is set to the
sequence
1,2,3 ,., n
, where
n=COUNT ( knownY )
.
If newX is omitted or an empty parameter (two consecutive ;; semicolons), it is set to be equal to
knownX.
If allowOffset is TRUE:
TREND=SLOPE( knownY ; knownX )newX +INTERCEPT (knownY ; knownX )
If allowOffset is FALSE:
anchor:TREND
TODO: Formula for this case.
Test Cases:
Expression Result Comment
=TREND( [.A19:.A23];
[.C19:.C23]; 1 )
4.755556
=TREND( [.A19:.A23];
[.C19:.C23]; 1; 0 )
1.682540
See also INTERCEPT, SLOPE , STEYX
6.18.80 TRIMMEAN
Summary: Returns the mean of a data set, ignoring a proportion of high and low values.
Syntax: TRIMMEAN( NumberSequenceList dataSet ; Number cutOffFraction )
Returns: Number
Constraints: 0 cutOffFraction < 1
Semantics: Returns the mean of a data set, ignoring a proportion of high and low values.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 384 of 442
Let n denote the number of elements in the data set and let
sortedDataSet
1,
sortedDataSet
2,
sortedDataSet
3,
, sortedDataSet
n
be the values in the data set sorted in ascending order. Moreover let
cutOff =INT
(
ncutOffFraction
2
)
Then TRIMMEAN returns the value
1
n2cutOff
i=cutOff +1
ncutOff
sortedDataSet
i
anchor:TRIMMEAN
Test Cases:
Expression Result Comment
=TRIMMEAN( [.A19:.A23];
0.8 )
4 cutOff = 2
=TRIMMEAN( [.A19:.A23];
0.6 )
4.666667
cutOff = INT(5 * 0.6/ 2) = INT(1.5) = 1;
result = 14 / 3
=TRIMMEAN( [.A19:.A23];
0.19 )
6.2 cutOff = 0
=TRIMMEAN( [.A19:.A23];
0.999999 )
4 cutOff = 2
=TRIMMEAN( [.A19:.A23];
1)
Error 0 <= cutOffFraction < 1
See also AVERAGE , GEOMEAN , HARMEAN
6.18.81 TTEST
Summary: Calculates the p-value of a 2-sample t-test.
Syntax: TTEST( ForceArray Array X ; ForceArray Array Y ; Integer tails ; Integer type )
Returns: Number
Constraints: COUNT(X)>1, COUNT(Y)>1, tails = 1 or 2, type = 1,2, or 3, (COUNT(X)=COUNT(Y)
or type 1)
COLUMNS(X) = COLUMNS(Y), ROWS(X) = ROWS(Y)
Semantics: Let X1, X2, ,Xn be the numbers in the sequence X and Y1, Y2, ,Ym be the numbers
in the sequence Y. Then
X=
1
n
i=1
n
X
i
and
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 385 of 442
Y =
1
m
i=1
m
Y
i
Moreover let
s
X
2
=
1
n1
i=1
n
( X
i
X)
2
s
Y
2
=
1
m1
i=1
m
(Y
i
Y )
2
and
f ( x , df )=
I
(
df +1
2
)
.
ndf I
(
df
2
)
(
1+
x
2
df
)
( df +1)
2
where is the Gamma function.
(1) If type = 1, TTEST calculates the p-value for a paired-sample comparison of means test.
Note that in this case due to the above constraints n=m. With
s
XY
2
=
1
n1
i=1
n
(( X
i
Y
i
)( XY ))
2
and
t =
X Y
.
s
X Y
2
. n
TTEST returns
tails
f ( x , n1)dx
(2) If type = 2, TTEST calculates the p-value of a comparison of means for independent
samples from populations with equal variance. With
s
p
2
=
(n1) s
X
2
+( m1) s
Y
2
n+m2
and
t =
XY
.
s
p
2
(
1
n
+
1
m
)
TTEST returns
tails
f ( x , n+m2)dx
(3) If type = 3, TTEST calculates the p-value of a comparison of means for independent
samples from populations with not necessarily equal variances. With
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 386 of 442
t =
XY
.
s
X
2
n
+
s
Y
2
m
and
v=
(
S
X
2
n
+
S
Y
2
m
)
2
(
S
X
2
n
)
2
(n1)
+
(
S
Y
2
m
)
2
(m1)
TTEST returns
tails
f ( x , v) dx
For an empty element or an element of type Text or Boolean in X the element at the corresponding
position of Y is ignored, and vice versa.
anchor:TTEST
Test Cases:
Expression Result Comment
=TTEST( [.A19:.A23];
[.A24:.A28]; 1; 1 )
0.042721
=TTEST( [.A19:.A23];
[.A24:.A28]; 2; 1 )
0.085441
=TTEST( [.A19:.A23];
[.A24:.A28]; 1; 2 )
0.029454
=TTEST( [.A19:.A23];
[.A24:.A28]; 1; 3 )
0.046213
=TTEST( [.A19:.A23];
[.A24:.A29]; 1; 1 )
Error same amount of numbers for paired samples
=TTEST( [.A19:.A19];
[.A24:.A24]; 1; 3 )
Error two numbers at least for each sequence
See also FTEST, LEGACY.TDIST, ZTEST
6.18.82 VAR
Summary: Compute the sample variance of a set of numbers.
Syntax: VAR( { NumberSequence N }
+
)
Returns: Number
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 387 of 442
Constraints: At least two numbers shall be included. Returns an Error if less than two Numbers are
provided.
Semantics: Computes the sample variance s
2
, where
s
2
=
1
n1
i=1
n
( x
i
x)
2
=
1
n1
((
i =1
n
x
i
2
)
n x
2
)
Note that s
2
is not the same as the variance of the set,
2
, which uses n rather than n 1.
anchor:VAR
Test Cases:
Expression Result Comment
=VAR(2;4) 2 The sample variance of (2;4) is 2.
=VAR([.B4:.B5])*2 1 The sample variance of (2;3) is 0.5.
=VAR([.B3:.B5])*2 1 Strings are not converted to numbers and are ignored.
=VAR(1) Error At least two numbers must be included
See also VARP, STDEV, AVERAGE
6.18.83 VARA
Summary: Estimates the variance using a sample set of values, including values of type Text and
Logical.
Syntax: VARA( { Any sample }
+
)
Returns: Number
Constraints: The sequence shall contain two numbers at least.
Semantics: Unlike the VAR function, includes values of type Text and Logical. Text values are
treated as number 0. Logical True is treated as 1, and False is treated as 0. Empty cells are not
included.
Given the expectation value
x
the estimated variance becomes
s
2
=
1
n1
i=1
n
( x
i
x)
2
=
1
n1
((
i =1
n
x
i
2
)
n x
2
)
In the sequence, only Numbers and Logical types are considered; cells with Text are converted to 0;
other types are ignored. If Logical types are a distinct type, they are still included, with True
considered 1 and False considered 0. Any sample may be of type ReferenceList.
The handling of string constants as parameters is implementation-defined. Either, string constants
are converted to numbers, if possible and otherwise, they are treated as zero, or string constants
are always treated as zero.
anchor:VARA
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 388 of 442
Test Cases:
Expression Result Comment
=VARA(2;4) 2 The sample variance of (2;4) is 2.
=VARA([.B5:.C6]) 6.666667 Logicals (referenced) are converted to numbers.
=VARA( TRUE(); FALSE() ) 1 Logicals (inlined) are converted to numbers.
=VARA(1) Error Two numbers at least.
See also VAR
Note:
OOo Calc (2.02): Treats strings as zero in VARA, even if they would be convertible. Ignores them for
VAR. Converts Logicals to {0,1} in both cases, VAR and VARA.
Gnumeric (1.6.1): Converts logicals and strings (if possible) for VARA. Ignores both in VAR.
6.18.84 VARP
Summary: Compute the variance of the set for a set of numbers.
Syntax: VARP( { NumberSequence N }
+
)
Returns: Number
Constraints: COUNT(N)>=1
Semantics: Computes the variance of the set
2
, where
c
2
=
1
n
i=1
n
( x
i
x)
2
=
1
n
((
i=1
n
x
i
2
)
n x
2
)
Note that
2
is not the same as the sample variance, s
2
, which uses n 1 rather than n.
If only one number is provided, returns 0.
anchor:VARP
Test Cases:
Expression Result Comment
=VARP(2;4) 1 The variance of the set for (2;4) is 1.
=VARP([.B4:.B5])*4 1 The variance of the set for (2;3) is 0.25.
=VARP([.B3:.B5])*4 1 Strings are not converted to numbers and are ignored.
See also VAR, STDEVP, AVERAGE
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 389 of 442
6.18.85 VARPA
Summary: Calculates the variance using the population of the distribution, including values of type
Text and Logical.
Syntax: VARPA( { Any sample }
+
)
Returns: Number
Constraints: None
Semantics: Unlike the VARP function, includes values of type Text and Logical. Text values are
treated as number 0. Logical True is treated as 1, and False is treated as 0. Empty cells are not
included.
Given the expectation value
x
the variance becomes
c
2
=
1
n
i=1
n
( x
i
x)
2
=
1
n
((
i=1
n
x
i
2
)
n x
2
)
In the sequence, only Numbers and Logical types are considered; cells with Text are converted to 0;
other types are ignored. If Logical types are a distinct type, they are still included, with True
considered 1 and False considered 0. Any sample may be of type ReferenceList.
The handling of string constants as parameters is implementation-defined. Either, string constants
are converted to numbers, if possible and otherwise, they are treated as zero, or string constants
are always treated as zero.
anchor:VARPA
Test Cases:
Expression Result Comment
=VARPA(2;4) 1 The sample variance of (2;4) is 1.
=VARPA([.B5:.C6]) 4 Logicals (referenced) are converted to numbers.
=VARPA( TRUE();
FALSE() )
0.5 Logicals (inlined) are converted to numbers.
See also VARP
Note:
OOo Calc (2.02): Treats strings as zero in VARA, even if they would be convertible. Ignores them for
VAR. Converts Logicals to {0,1} in both cases, VAR and VARA.
Gnumeric (1.6.1): Converts logicals and strings (if possible) for VARA. Ignores both in VAR.
6.18.86 WEIBULL
Summary: Calculates the Weibull distribution.
Syntax: WEIBULL( Number value ; Number alpha ; Number beta ; Logical cumulative )
Returns: Number
Constraints: value >= 0; shape > 0; scale > 0
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 390 of 442
Semantics: Calculates the Weibull distribution at the position value.
If cumulative is false, the probability density function is calculated:
shape
scale
(
value
scale
)
shape1
e
(
value
scale
)
shape
If cumulative is true, the cumulative distribution function is calculated:
1e
(
value
scale
)
shape
anchor:WEIBULL
Test Cases:
Expression Result Comment
=WEIBULL( 2; 3; 4; 0 ) 0.165468 pdf
=WEIBULL( 2; 3; 4; 1 ) 0.117503 cdf
=WEIBULL( -1; 3; 4; 0 ) Error value >= 0
=WEIBULL( 2; 0; 4; 0 ) Error alpha > 0
=WEIBULL( 2; 3; 0; 0 ) Error beta > 0
See also BETADIST, BINOMDIST, CHISQDIST, EXPONDIST, FDIST, GAMMADIST, GAUSS,
HYPGEOMDIST, LOGNORMDIST, NEGBINOMDIST, NORMDIST, POISSON, LEGACY.TDIST
6.18.87 ZTEST
Summary: Calculates the probability of observing a sample mean as large or larger than the mean
of the given sample for samples drawn from a normal distribution.
Syntax: ZTEST( NumberSequenceList sample ; Number mean [ ; Number sigma ] )
Returns: Number
Constraints: The sequence sample shall contain at least two numbers.
Semantics: Calculates the probability of observing a sample mean as large or larger than the mean
of the given sample for samples drawn from a normal distribution with the given mean mean and the
given standard deviation sigma. If sigma is omitted, it is estimated from sample, using STDEV. With
sample being the mean of sample and
z=
samplemean
sigma
.n
ZTEST returns
P ( zZ )=
1
.2n
x
2
2
dx
anchor:ZTEST
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 391 of 442
Test Cases:
Expression Result Comment
=ZTEST( [.B4:.C5]; 3.5 ) 0
mean = average, estimated standard deviation:
fits well
=ZTEST( [.B4:.C5]; 3; 2 ) 0.382925
mean near average, standard deviation greater than
estimate:
probable
=ZTEST( [.B4:.C5]; 4; 0.5) 0.954500
mean near the average, but small deviation:
not probable
=ZTEST( [.B4:.C5]; 5 ) 0.979863
mean at a border value, standard deviation ~ 1,3:
nearly improbable
=ZTEST( [.B4:.C5]; 5; 0.1 ) 1
mean at a border value, small standard deviation:
improbable
See also FTEST, TTEST
6.19 Number Representation Conversion Functions
6.19.1 General
These functions convert between different representations of numbers, such as between different
bases and Roman numerals.
The base conversion functions xxx2BIN (such as DEC2BIN), xxx2OCT, and xxx2HEX functions
return Text, while the xxx2DEC functions return Number. All of the xxx2yyy functions accept either
Text or Number, though a Number is interpreted as the digits when printed in base 10. These are
intended to support relatively small numbers, and have a somewhat convoluted interface and
semantics, as described in their specifications. General base conversion capabilities are provided by
BASE and DECIMAL.
As an argument for the HEX2xxx functions, a hexadecimal number is any string consisting solely of
the characters "0","1" to "9", "a" to "f" and "A" to "F". The hexadecimal output of an xxx2HEX
function _shall_ be a string consisting solely of the characters "0","1" to "9" (U+0030 through
U+0039), "a" to "f" (U+0061 through U+0066) and "A" to "F" (U+0041 through U+0046), and should
be a string consisting solely of the characters "0","1" to "9" and "A" to "F". In both cases, the 40th bit
(from the right) is considered a sign bit.
6.19.2 ARABIC
Summary: Convert Roman numerals to Number.
Syntax: ARABIC( Text X )
Returns: Number
Constraints: X shall contain Roman numerals, or an empty string.
Semantics: Converts the Roman numeral to Number. This is the reverse of ROMAN; see ROMAN
for the values of individual Roman numeral symbols. A Roman symbol to the left of a larger symbol
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 392 of 442
(directly or indirectly) reduces the final value by the symbol amount, otherwise, it increases the final
amount by the symbol's amount. Case is ignored.
The following identity shall hold: ARABIC(ROMAN(x; any)) = x, when ROMAN(x; any) is not an
Error.
If X is an empty string, 0 is returned.
anchor:ARABIC
Note: Historically, larger numbers were written by writing an overbar over the characters (which
multiplied them by 1,000); today Roman numerals are not usually used for numbers large enough to
justify mandating support for this, and supporting them is complicated since many character
systems cannot handle them.
Test Cases:
Expression Result Comment
=ARABIC("I") 1 Simple value
=ARABIC("CDLII") 452 452
=ARABIC("MCDXC") 1490 1490
=ARABIC("MDCCCXCIX") 1899 1899
=ARABIC("MCMXCIX") 1999 1999
=ARABIC("MMCMXCIII") 2993 2993
=ARABIC("MMMCMXCIX") 3999 3999, the largest portable value for this function.
=ARABIC("mmmcmxcix") 3999 Case is ignored
=ARABIC("MIM") 1999
ARABIC can handle non-traditional
representations of Roman numerals
=ARABIC("IVX") Error V may not be followed by X
See also Infix Operator "&", ROMAN
Note: This is a well-known missing function in MS Excel. For example, Walkenbach's "Excel 2003
Formulas" page 163 notes how odd it is that Excel lacks this kind of functionality. This function is
already implemented in OpenOffice.org Calc and in Kspread.
6.19.3 BASE
Summary: Converts a number into a text representation with the given base.
Syntax: BASE( Integer X ; Integer Radix [ ; Integer MinimumLength ] )
Returns: Text
Constraints: X 0, 2 Radix 36, MinimumLength 0
Semantics: Converts number X into text that represents the value of X in base Radix. The symbols
0-9 (U+0030 through U+0039), then upper case A-Z (U+0041 through U+005A) are used as digits.
Thus, BASE(45745;36) returns ZAP.
100414201 29 May 2010
Copyright OASIS Open 2002 - 2010. All Rights Reserved. Page 393 of 442
If MinimumLength is not supplied, the generated text uses the smallest number of characters (i.e., it
does not add leading 0s). If MinimumLength is supplied, and the resulting text would normally be
smaller than MinimumLength, leading 0s are added to produce text exactly MinimumLength
characters long. If the text is longer than the MinimumLength argument, the MinimumLength
parameter is ignored.
anchor:BASE
Test Cases:
Expression Result Comment
=BASE(23;10) "23" Base 10 is permitted as a Radix
=BASE(6;2) 110 Base 2.
=BASE(0;3) 0
0 is the same in any base. Base 3 is supported,
too
=BASE(6;2;4) 0110 Base 2.
=BASE(6;2;1) 110 If minimum is too small, it's ignored
=BASE(45745;36) "ZAP"
Base 36 is sometimes used to encode values; it
is handy for such purposes, since all digits and
letters A-Z can be used. Uppercase letters used.
=ISTEXT(BASE(6;2)) True BASE produces values of type Text.
=ISNUMBER(BASE(6;2)) False BASE produces values of type Text, not Number.
=BASE(10;16) A Base 16 (hexadecimal)
=BASE(1025;2)
10000000001