NOTE: This is the TestCases web. You cannot edit any topic named "TestCase..." or "Web..." in this web, you can only create new topics. Any topics you do create that are not checked into subversion may be deleted by anyone, at any time.
Description: Tag tests that can be automated

run this test

Designed by: Kenneth Lavrsen

ABOVE( ) -- address range of cells above the current cell

Test Expected Actual
4 4 4
-5 -5 -5
0 0 0
11 11 11
%CALC{"$ABOVE()"}% R0:C3..R5:C3 R1:C3..R5:C3

ABS( num ) -- absolute value of a number

  • Test: %CALC{"$ABS(-12.5)"}%
  • Expected: 12.5
  • Actual: 12.5

  • Test: %CALC{"$ABS(12.5)"}%
  • Expected: 12.5
  • Actual: 12.5

  • Test: %CALC{"$ABS(0)"}%
  • Expected: 0
  • Actual: 0

AND( list ) -- logical AND of a list

Test Expected Actual
%CALC{"$AND(0, 0, 0)"}% 0 0
%CALC{"$AND(0, 0, 1)"}% 0 0
%CALC{"$AND(0, 1, 0)"}% 0 0
%CALC{"$AND(0, 1, 1)"}% 0 0
%CALC{"$AND(1, 0, 0)"}% 0 0
%CALC{"$AND(1, 0, 1)"}% 0 0
%CALC{"$AND(1, 1, 0)"}% 0 0
%CALC{"$AND(1, 1, 1)"}% 1 1

AVERAGE( list ) -- average of a list or a range of cells

Test Expected Actual
10 10 10
12 12 12
11 11 11
14 14 14
%CALC{"$AVERAGE($ABOVE())"}% 11.75 11.75

CHAR( number ) -- ASCII character represented by number

  • Test: %CALC{"$CHAR(97)"}%
  • Expected: a
  • Actual: a

CODE( text ) -- ASCII numeric value of character

  • Test: %CALC{"$CODE(abc)"}%
  • Expected: 97
  • Actual: 97

COLUMN( offset ) -- current column number

Test Expected Actual
Normal 2 3
Test %CALC{"$COLUMN()"}% A B
Expected 2 B
Actual 2 B
     
Offset 2    
Test %CALC{"$COLUMN(2)"}% A B
Expected 4 B
Actual 4 B
     
Offset -1    
Test %CALC{"$COLUMN(-1)"}% A B
Expected 1 B
Actual 1 B

COUNTITEMS( list ) -- count individual items in a list

Test Expected Actual
A A A
A A A
B B B
C C C
C C C
C C C
C C C
C C C
%CALC{"$COUNTITEMS(R2:C2..R9:C2)"}% A: 2
B: 1
C: 5
A: 2
B: 1
C: 5

Test Expected Actual
%CALC{"$COUNTITEMS(R1:C2..R1:C2)"}% Expected: 1 Expected: 1

COUNTSTR( list, str ) -- count the number of cells in a list equal to a given string

  • Count the number of cells in a list equal to a given string (if str is specified), or counts the number of non empty cells in a list
  • Syntax: $COUNTSTR( list, str )
  • Example: %CALC{"$COUNTSTR($ABOVE())"}% counts the number of non empty cells above the current cell
  • Example: %CALC{"$COUNTSTR($ABOVE(), DONE)"}% counts the number of cells equal to DONE
  • Related: $COUNTITEMS(), $LIST()

DEF( list ) -- find first non-empty list item or cell

  • Returns the first list item or cell reference that is not empty
  • Syntax: $DEF( list )
  • Example: %CALC{"$DEF(R1:C1..R1:C3)"}%
  • Related: $COUNTSTR(), $LISTIF(), $LIST()

EMPTY( text ) -- test for empty text

  • Test: %CALC{"$EMPTY(foo)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$EMPTY()"}%
  • Expected: 1
  • Actual: 1

  • Test: %CALC{"$CODE(abc)"}%
  • Expected: 1
  • Actual: 1

EVAL( formula ) -- evaluate a simple mathematical formula

  • Addition, substraction, multiplication, division and modulus of numbers are supported. Any nesting is permitted
  • Numbers may be decimal integers (1234), binary integers (0b1110011), octal integers (01234), hexadecimal integers (0x1234) or of exponential notation (12.34e-56)
  • Syntax: $EVAL( formula )
  • Example: %CALC{"$EVAL( (5 * 3) / 2 + 1.1 )"}% returns 8.6
  • Related: $EXEC(), $INT(), $MOD(), $ROUND(), $VALUE()

EVEN( num ) -- test for even number

EXACT( text1, text2 ) -- compare two text strings

  • Compares two text strings and returns 1 if they are exactly the same, or 0 if not
  • Syntax: $EXACT( text1, text2 )
  • Example: %CALC{"$EXACT(foo, Foo)"}% returns 0
  • Example: %CALC{"$EXACT(foo, $LOWER(Foo))"}% returns 1
  • Related: $EMPTY(), $IF(), $TRIM()

EXEC( formula ) -- execute a spreadsheet formula

  • Execute a spreadsheet formula, typically retrieved from a variable. This can be used to store a formula in a variable once and execute it many times using different parameters.
  • Syntax: $EXEC( formula )
  • Example: %CALC{"$SET(msg, $NOEXEC(Hi $GET(name)))"}% sets the msg variable with raw formula Hi $GET(name)
  • Example: %CALC{"$SET(name, Tom) $EXEC($GET(msg))"}% executes content of msg variable and returns Hi Tom
  • Example: %CALC{"$SET(name, Jerry) $EXEC($GET(msg))"}% returns Hi Jerry
  • Related: $EVAL(), $GET(), $NOEXEC(), $SET()

EXISTS( topic ) -- check if topic exists

  • Topic can be TopicName or a Web.TopicName. Current web is used if web is not specified.
  • Syntax: $EXISTS( topic )
  • Example: %CALC{"$EXISTS(StronaGlowna)"}% returns 1
  • Example: %CALC{"$EXISTS(ThisDoesNotExist)"}% returns 0
  • Related: $EXACT(), $IF(), $TRIM()

EXP( num ) -- exponent (e) raised to the power of a number

  • EXP is the inverse of the LN function
  • Syntax: $EXP( num )
  • Example: %CALC{"$EXP(1)"}% returns 2.71828182845905
  • Related: $LN(), $LOG()

FIND( string, text, start ) -- find one string within another string

  • Test: %CALC{"$FIND(f, fluffy)"}%
  • Expected: 1
  • Actual: 1

  • Test: %CALC{"$FIND(f, fluffy, 2)"}%
  • Expected: 4
  • Actual: 4

  • Test: %CALC{"$FIND(y, fluffy, 6)"}%
  • Expected: 6
  • Actual: 6

  • Test: %CALC{"$FIND(u, fluffy, 6)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$FIND(@, fluffy, 1)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$FIND(, fluffy, 0)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$FIND(f, , 0)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$FIND(,,)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$FIND(f, fluffy, 9)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$FIND(kit, fluffy kitten)"}%
  • Expected: 8
  • Actual: 8

FORMAT( type, precision, number ) -- format a number to a certain type and precision

  • Supported type:
    • COMMA for comma format, such as 12,345.68
    • DOLLAR for Dollar format, such as $12,345.68
    • KB for Kilo Byte format, such as 1205.63 KB
    • MB for Mega Byte format, such as 1.18 MB
    • KBMB for Kilo/Mega/Giga/Tera Byte auto-adjust format
    • NUMBER for number, such as 12345.7
    • PERCENT for percent format, such as 12.3%
  • The precision indicates the the number of digits after the dot
  • Syntax: $FORMAT( type, prec, number )
  • Example: %CALC{"$FORMAT(COMMA, 2, 12345.6789)"}% returns 12,345.68
  • Example: %CALC{"$FORMAT(DOLLAR, 2, 12345.67)"}% returns $12,345.68
  • Example: %CALC{"$FORMAT(KB, 2, 1234567)"}% returns 1205.63 KB
  • Example: %CALC{"$FORMAT(MB, 2, 1234567)"}% returns 1.18 MB
  • Example: %CALC{"$FORMAT(KBMB, 2, 1234567)"}% returns 1.18 MB
  • Example: %CALC{"$FORMAT(KBMB, 2, 1234567890)"}% returns 1.15 GB
  • Example: %CALC{"$FORMAT(NUMBER, 1, 12345.67)"}% returns 12345.7
  • Example: %CALC{"$FORMAT(PERCENT, 1, 0.1234567)"}% returns 12.3%
  • Related: $FORMATTIME(), $FORMATTIMEDIFF(), $ROUND()

FORMATGMTIME( serial, text ) -- convert a serialized date into a GMT date string

FORMATTIME( serial, text ) -- convert a serialized date into a date string

  • The following formatting tokens in text are expanded: $second (seconds, 00..59); $minute (minutes, 00..59); $hour (hours, 00..23); $day (day of month, 01..31); $month (month, 01..12); $mon (month in text format, Jan..Dec); $year (4 digit year, 1999); $ye (2 digit year, 99), $wd (day number of the week, 1 for Sunday, 2 for Monday, etc), $wday (day of the week, Sun..Sat), $weekday (day of the week, Sunday..Saturday), $yearday (day of the year, 1..365, or 1..366 in leap years). Date is assumed to be server time; add GMT to indicate Greenwich time zone.
  • Syntax: $FORMATTIME( serial, text )
  • Example: %CALC{"$FORMATTIME(0, $year/$month/$day GMT)"}% returns 1970/01/01 GMT
  • Related: $FORMATGMTIME(), $TIME(), $FORMATTIMEDIFF(), $TIMEADD(), $TIMEDIFF(), $TODAY()

FORMATTIMEDIFF( unit, precision, time ) -- convert elapsed time to a string

  • Convert elapsed time to a human readable format, such as: 12 hours and 3 minutes
  • The input unit can be second, minute, hour, day, month, year. Note: An approximation is used for month and year calculations.
  • The precision indicates the number of output units to use
  • Syntax: $FORMATTIMEDIFF( unit, precision, time )
  • Example: %CALC{"$FORMATTIMEDIFF(min, 1, 200)"}% returns 3 hours
  • Example: %CALC{"$FORMATTIMEDIFF(min, 2, 200)"}% returns 3 hours and 20 minutes
  • Example: %CALC{"$FORMATTIMEDIFF(min, 1, 1640)"}% returns 1 day
  • Example: %CALC{"$FORMATTIMEDIFF(min, 2, 1640)"}% returns 1 day and 3 hours
  • Example: %CALC{"$FORMATTIMEDIFF(min, 3, 1640)"}% returns 1 day, 3 hours and 20 minutes
  • Related: $FORMATTIME(), $TIME(), $TIMEADD(), $TIMEDIFF()

GET( name ) -- get the value of a previously set variable

  • Specify the variable name (alphanumeric characters and underscores). An empty string is returned if the variable does not exist. Use $SET() to set a variable first. Unlike table ranges, variables live for the time of the page view and persist across tables, i.e. you can use it to summarize results across several tables.
  • Syntax: $GET( name )
  • Example: %CALC{"$GET(my_total)"}% returns the value of the my_total variable
  • Related: $EXEC(), $NOEXEC(), $SET(), $SETIFEMPTY(), $SETM()

IF( condition, value if true, value if 0 ) -- return a value based on a condition

  • The condition can be a number (where 0 means condition not met), or two numbers with a comparison operator < (less than), <= (less than or equal), == (equal), != (not equal), >= (greater than or equal), > (greater than).
  • Syntax: $IF( condition, value if true, value if 0 )
  • Example: %CALC{"$IF($T(R1:C5) > 1000, Over Budget, OK)"}% returns Over Budget if value in R1:C5 is over 1000, OK if not
  • Example: %CALC{"$IF($EXACT($T(R1:C2),), empty, $T(R1:C2))"}% returns the content of R1:C2 or empty if empty
  • Example: %CALC{"$SET(val, $IF($T(R1:C2) == 0, zero, $T(R1:C2)))"}% sets a variable conditionally
  • Related: $AND(), $EMPTY(), $EXACT(), $LISTIF(), $NOT(), $OR()

INSERTSTRING( text, start, new ) -- insert a string into a text string

  • Test: %CALC{"$INSERTSTRING(abcdefg, 0, XYZ)"}%
  • Expected: XYZabcdefg
  • Actual: XYZabcdefg

  • Test: %CALC{"$INSERTSTRING(a, 0, XYZ)"}%
  • Expected: XYZa
  • Actual: XYZa

  • Test: %CALC{"$INSERTSTRING(, 0, XYZ)"}%
  • Expected: XYZ
  • Actual: XYZ

  • Test: %CALC{"$INSERTSTRING(abcdefg, 1, XYZ)"}%
  • Expected: aXYZbcdefg
  • Actual: aXYZbcdefg

  • Test: %CALC{"$INSERTSTRING(a, 1, XYZ)"}%
  • Expected: aXYZ
  • Actual: aXYZ

  • Test: %CALC{"$INSERTSTRING(, 1, XYZ)"}%
  • Expected:
  • Actual:

  • Test: %CALC{"$INSERTSTRING(abcdefg, 3, XYZ)"}%
  • Expected: abcXYZdefg
  • Actual: abcXYZdefg

  • Test: %CALC{"$INSERTSTRING(abcdefghijk, 3, )"}%
  • Expected: abcdefghijk
  • Actual: abcdefghijk

  • Test: %CALC{"$INSERTSTRING(abcdefg, 7, XYZ)"}%
  • Expected: abcdefgXYZ
  • Actual: abcdefgXYZ

  • Test: %CALC{"$INSERTSTRING(abcdefg, 8, XYZ)"}%
  • Expected: abcdefg
  • Actual: abcdefg

  • Test: %CALC{"$INSERTSTRING(abcdefg, 12, XYZ)"}%
  • Expected: abcdefg
  • Actual: abcdefg

  • Test: %CALC{"$INSERTSTRING(abcdefg, -5, XYZ)"}%
  • Expected: abXYZcdefg
  • Actual: abXYZcdefg

  • Test: %CALC{"$INSERTSTRING(abcdefg, -7, XYZ)"}%
  • Expected: XYZabcdefg
  • Actual: XYZabcdefg

  • Test: %CALC{"$INSERTSTRING(abcdefg, -12, XYZ)"}%
  • Expected: abcdefg
  • Actual: abcdefg

INT( formula ) -- evaluate formula and round down to nearest integer

  • Addition, substraction, multiplication, division and modulus of numbers are supported. Any nesting is permitted
  • Numbers may be decimal integers (1234), binary integers (0b1110011), octal integers (01234), hexadecimal integers (0x1234) or of exponential notation (12.34e-56)
  • If you expect a single decimal integer value with leading zeros, use $INT( $VALUE( number ) )
  • Syntax: $INT( formula )
  • Example: %CALC{"$INT(10 / 4)"}% returns 2
  • Example: %CALC{"$INT($VALUE(09))"}% returns 9
  • Related: $EVAL(), $ROUND(), $VALUE()

LEFT( ) -- address range of cells to the left of the current cell

  • Syntax: $LEFT( )
  • Example: %CALC{"$SUM($LEFT())"}% returns the sum of cells to the left of the current cell
  • Related: $ABOVE(), $RIGHT()

LEFTSTRING( text, num ) -- extract characters at the beginning of a text string

  • Test: %CALC{"$LEFTSTRING(abcdefg)"}%
  • Expected: a
  • Actual: a

  • Test: %CALC{"$LEFTSTRING(abcdefg, 0)"}%
  • Expected:
  • Actual:

  • Test: %CALC{"$LEFTSTRING(abcdefg, 5)"}%
  • Expected: abcde
  • Actual: abcde

  • Test: %CALC{"$LEFTSTRING(abcdefg, 12)"}%
  • Expected: abcdefg
  • Actual: abcdefg

  • Test: %CALC{"$LEFTSTRING(abcdefg, -3)"}%
  • Expected: abcd
  • Actual: abcd

  • Test: %CALC{"$LEFTSTRING(abcdefg, -12)"}%
  • Expected:
  • Actual:

LENGTH( text ) -- length of text in bytes

  • Syntax: $LENGTH( text )
  • Example: %CALC{"$LENGTH(abcd)"}% returns 4
  • Related: $LISTSIZE()

LIST( range ) -- convert content of a cell range into a list

LISTIF( condition, list ) -- remove elements from a list that do not meet a condition

LISTITEM( index, list ) -- get one element of a list

LISTJOIN( separator, list ) -- convert a list into a string

  • By default, list items are separated by a comma and a space. Use this function to indicate a specific separator string, which may include $comma for comma, $n for newline, and $sp for space.
  • Syntax: $LISTJOIN( separator, list )
  • Example: %CALC{"$LISTJOIN($n, Apple, Orange, Apple, Kiwi)"}% returns the four items separated by new lines
  • Related: $LIST(), $LISTSIZE()

LISTMAP( formula, list ) -- evaluate and update each element of a list

LISTRAND( list ) -- get one random element of a list

LISTREVERSE( list ) -- opposite order of a list

LISTSIZE( list ) -- number of elements in a list

LISTSHUFFLE( list ) -- shuffle element of a list in random order

LISTSORT( list ) -- sort a list

LISTTRUNCATE( size, list ) -- truncate list to size

LISTUNIQUE( list ) -- remove all duplicates from a list

LN( num ) -- natural logarithm of a number

  • LN is the inverse of the EXP function
  • Syntax: $LN( num )
  • Example: %CALC{"$LN(10)"}% returns 2.30258509299405
  • Related: $EXP(), $LOG()

LOG( num, base ) -- logarithm of a number to a given base

  • base-10 logarithm of a number (if base is 0 or not specified), else logarithm of a number to the given base
  • Syntax: $LOG( num, base )
  • Example: %CALC{"$LOG(1000)"}% returns 3
  • Example: %CALC{"$LOG(16, 2)"}% returns 4
  • Related: $EXP(), $LN()

LOWER( text ) -- lower case string of a text

MAX( list ) - biggest value of a list or range of cells

MEDIAN( list ) -- median of a list or range of cells

MIN( list ) -- smallest value of a list or range of cells

MOD( num, divisor ) -- reminder after dividing num by divisor

  • Syntax: $MOD( num, divisor )
  • Example: %CALC{"$MOD(7, 3)"}% returns 1
  • Related: $EVAL()

NOEXEC( formula ) -- do not execute a spreadsheet formula

  • Prevent a formula from getting executed. This is typically used to store a raw formula in a variable for later use as described in $EXEC().
  • Syntax: $NOEXEC( formula )
  • Example: %CALC{"$SET(msg, $NOEXEC(Hi $GET(name)))"}% sets the msg variable with the formula Hi $GET(name) without executing it
  • Related: $EVAL(), $EXEC(), $GET(), $SET()

NOP( text ) -- no-operation

  • Useful to change the order of Plugin execution. For example, it allows preprossing to be done before %SEARCH{}% is evaluated. The percent character '%' can be escaped with $per
  • Syntax: $NOP( text )

NOT( num ) -- reverse logic of a number

  • Returns 0 if num is not zero, 1 if zero
  • Syntax: $NOT( num )
  • Example: %CALC{"$NOT(0)"}% returns 1
  • Related: $AND(), $EMPTY(), $IF(), $OR()

ODD( num ) -- test for odd number

OR( list ) -- logical OR of a list

  • Syntax: $OR( list )
  • Example: %CALC{"$OR(1, 0, 1)"}% returns 1
  • Related: $AND(), $IF(), $NOT()

PERCENTILE( num, list ) -- percentile of a list or range of cells

  • Calculates the num-th percentile, useful to establish a threshold of acceptance. num is the percentile value, range 0..100
  • Syntax: $PERCENTILE( num, list )
  • Example: %CALC{"$PERCENTILE(75, 400, 200, 500, 100, 300)"}% returns 450
  • Related: $LIST(), $MAX(), $MEDIAN(), $MIN()

PI( ) -- mathematical constant Pi, 3.14159265358979

  • Syntax: $PI( )
  • Example: %CALC{"$PI()"}% returns 3.14159265358979

PRODUCT( list ) -- product of a list or range of cells

  • Syntax: $PRODUCT( list )
  • Example: To calculate the product of the cells to the left of the current one use %CALC{"$PRODUCT($LEFT())"}%
  • Related: $LIST(), $PRODUCT(), $SUM(), $SUMPRODUCT()

PROPER( text ) -- properly capitalize text

  • Capitalize letters that follow any character other than a letter; convert all other letters to lowercase letters
  • Syntax: $PROPER( text )
  • Example: %CALC{"$PROPER(a small STEP)"}% returns A Small Step
  • Example: %CALC{"$PROPER(f1 (formula-1))"}% returns F1 (Formula-1)
  • Related: $LOWER(), $PROPERSPACE(), $TRIM(), $UPPER()

PROPERSPACE( text ) -- properly space out WikiWords

  • Properly spaces out WikiWords preceeded by white space, parenthesis, or ][. Words listed in the DONTSPACE DefaultPreferences variable or DONTSPACE Plugins setting are excluded
  • Syntax: $PROPERSPACE( text )
  • Example: Assuming DONTSPACE contains MacDonald: %CALC{"$PROPERSPACE(Old MacDonald had a ServerFarm, EeEyeEeEyeOh)"}% returns Old MacDonald had a Server Farm, Ee Eye Ee Eye Oh
  • Related: $LOWER(), $PROPER(), $TRIM(), $UPPER()

RAND( max ) -- random number

REPEAT( text, num ) -- repeat text a number of times

  • Syntax: $REPEAT( text, num )
  • Example: %CALC{"$REPEAT(/\, 5)"}% returns /\/\/\/\/\

REPLACE( text, start, num, new ) -- replace part of a text string

  • Test: %CALC{"$REPLACE(abcdefghijk, 6, 5, *)"}%
  • Expected: abcde*k
  • Actual: abcde*k

  • Test: %CALC{"$REPLACE(10xxx, 2, 1, .)"}%
  • Expected: 1.xxx
  • Actual: 1.xxx

  • Test: %CALC{"$REPLACE(, 2, 1, .)"}%
  • Expected:
  • Actual:

  • Test: %CALC{"$REPLACE(10xxx, 2, 1, )"}%
  • Expected: 1xxx
  • Actual: 1xxx

  • Test: %CALC{"$REPLACE(10xxx, -2, 1, *)"}%
  • Expected: 10x*x
  • Actual: 10x*x

  • Test: %CALC{"$REPLACE(10xxx, 2, 0, *)"}% (replace nothing at a position is actually same as inserting)
  • Expected: 1*0xxx
  • Actual: 1*0xxx

RIGHT( ) -- address range of cells to the right of the current cell

  • Syntax: $RIGHT( )
  • Example: %CALC{"$SUM($RIGHT())"}% returns the sum of cells to the right of the current cell
  • Related: $ABOVE(), $LEFT()

RIGHTSTRING( text, num ) -- extract characters at the end of a text string

  • Test: %CALC{"$RIGHTSTRING(abcdefg)"}%
  • Expected: g
  • Actual: g

  • Test: %CALC{"$RIGHTSTRING(abcdefg, 0)"}%
  • Expected:
  • Actual:

  • Test: %CALC{"$RIGHTSTRING(abcdefg, 5)"}%
  • Expected: cdefg
  • Actual: cdefg

  • Test: %CALC{"$RIGHTSTRING(abcdefg, 7)"}%
  • Expected: abcdefg
  • Actual: abcdefg

  • Test: %CALC{"$RIGHTSTRING(abcdefg, 10)"}%
  • Expected: abcdefg
  • Actual: abcdefg

  • Test: %CALC{"$RIGHTSTRING(abcdefg, -2)"}%
  • Expected:
  • Actual:

ROUND( formula, digits ) -- round a number

  • Evaluates a simple formula and rounds the result up or down to the number of digits if digits is positive; to the nearest integer if digits is missing; or to the left of the decimal point if digits is negative
  • Syntax: $ROUND( formula, digits )
  • Example: %CALC{"$ROUND(3.15, 1)"}% returns 3.2
  • Example: %CALC{"$ROUND(3.149, 1)"}% returns 3.1
  • Example: %CALC{"$ROUND(-2.475, 2)"}% returns -2.48
  • Example: %CALC{"$ROUND(34.9, -1)"}% returns 30
  • Related: $INT(), $FORMAT()

ROW( offset ) -- current row number

  • The current table row number with an optional offset
  • Syntax: $ROW( offset )
  • Example: To get the number of rows excluding table heading (first row) and summary row (last row you are in), write: %CALC{"$ROW(-2)"}%
  • Related: $COLUMN(), $T()

SEARCH( string, text, start ) -- search a string within a text

  • Test: %CALC{"$SEARCH([uy], fluffy)"}%
  • Expected: 3
  • Actual: 3

  • Test: %CALC{"$SEARCH([uy], fluffy, 4)"}%
  • Expected: 6
  • Actual: 6

  • Test: %CALC{"$FIND([ua], fluffy, 6)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$SEARCH([abc], fluffy,)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$SEARCH(, fluffy, 0)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$SEARCH(f, , 0)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$SEARCH(,,)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$SEARCH(f, fluffy, 9)"}%
  • Expected: 0
  • Actual: 0

  • Test: %CALC{"$SEARCH(k[ia]t, fluffy kitten)"}%
  • Expected: 8
  • Actual: 8

SET( name, value ) -- set a variable for later use

  • Specify the variable name (alphanumeric characters and underscores) and the value. The value may contain a formula; formulae are evaluated before the variable assignment; see $NOEXEC() if you want to prevent that. This function returns no output. Use $GET() to retrieve variables. Unlike table ranges, variables live for the time of the page view and persist across tables, i.e. you can use it to summarize results across several tables and also across included topics
  • Syntax: $SET( name, value )
  • Example: %CALC{"$SET(my_total, $SUM($ABOVE()))"}% sets the my_total variable to the sum of all table cells located above the current cell and returns an empty string
  • Related: $EXEC(), $GET(), $NOEXEC(), $SETIFEMPTY(), SETM()

SETIFEMPTY( name, value ) -- set a variable only if empty

  • Specify the variable name (alphanumeric characters and underscores) and the value.
  • Syntax: $SETIFEMPTY( name, value )
  • Example: %CALC{"$SETIFEMPTY(result, default)"}% sets the result variable to default if the variable is empty or 0; in any case an empty string is returned
  • Related: $GET(), $SET()

SETM( name, formula ) -- update an existing variable based on a formula

  • Specify the variable name (alphanumeric characters and underscores) and the formula. The formula must start with an operator to + (add), - (subtract), * (multiply), or / (divide) something to the variable. This function returns no output. Use $GET() to retrieve variables
  • Syntax: $SETM( name, formula )
  • Example: %CALC{"$SETM(total, + $SUM($LEFT()))"}% adds the sum of all table cells on the left to the total variable, and returns an empty string
  • Related: $GET(), $SET(), $SETIFEMPTY()

SIGN( num ) -- sign of a number

SQRT( num ) -- square root of a number

  • Syntax: $SQRT( num )
  • Example: %CALC{"$SQRT(16)"}% returns 4

SUBSTITUTE( text, old, new, instance, option ) -- substitute text

  • Test: %CALC{"$SUBSTITUTE(Good morning, morning, day)"}%
  • Expected: Good day
  • Actual: Good day

  • Test: %CALC{"$SUBSTITUTE(Q2-2002, 2, 3)"}%
  • Expected: Q3-3003
  • Actual: Q3-3003

  • Test: %CALC{"$SUBSTITUTE(Q2-2002,2, 3, 3)"}%
  • Expected: Q2-2003
  • Actual: Q2-2003

  • Test: %CALC{"$SUBSTITUTE(abc123def, [0-9], 9, , r)"}%
  • Expected: abc999def
  • Actual: abc999def

  • Test: %CALC{"$SUBSTITUTE(Q2-2002, , )"}%
  • Expected: Q2-2002
  • Actual: Q2-2002

  • Test: %CALC{"$SUBSTITUTE(, 2, 3)"}%
  • Expected:
  • Actual:

SUBSTRING( text, start, num ) -- extract a substring out of a text string

  • Test: %CALC{"$SUBSTRING(abcdefghijk, 0, 0)"}%
  • Expected:
  • Actual:

  • Test: %CALC{"$SUBSTRING(abcdefghijk, 0, 4)"}%
  • Expected:
  • Actual:

  • Test: %CALC{"$SUBSTRING(abcdefghijk, 0, 15)"}%
  • Expected:
  • Actual:

  • Test: %CALC{"$SUBSTRING(abcdefghijk, 1, 0)"}%
  • Expected:
  • Actual:

  • Test: %CALC{"$SUBSTRING(abcdefghijk, 1, 4)"}%
  • Expected: abcd
  • Actual: abcd

  • Test: %CALC{"$SUBSTRING(abcdefghijk, 1, 15)"}%
  • Expected: abcdefghijk
  • Actual: abcdefghijk

  • Test: %CALC{"$SUBSTRING(abcdefghijk, 3, 0)"}%
  • Expected:
  • Actual:

  • Test: %CALC{"$SUBSTRING(abcdefghijk, 3, 4)"}%
  • Expected: cdef
  • Actual: cdef

  • Test: %CALC{"$SUBSTRING(abcdefghijk, 3, 12)"}%
  • Expected: cdefghijk
  • Actual: cdefghijk

  • Test: %CALC{"$SUBSTRING(abcdefghijk, 12, 0)"}%
  • Expected:
  • Actual:

  • Test: %CALC{"$SUBSTRING(abcdefghijk, 12, 3)"}%
  • Expected:
  • Actual:

  • Test: %CALC{"$SUBSTRING(abcdefghijk, -5, 0)"}%
  • Expected:
  • Actual:

  • Test: %CALC{"$SUBSTRING(abcdefghijk, -5, 4)"}%
  • Expected: ghij
  • Actual: ghij

  • Test: %CALC{"$SUBSTRING(abcdefghijk, -5, 12)"}%
  • Expected: ghijk
  • Actual: ghijk

SUM( list ) -- sum of a list or range of cells

Test Expected Actual
4 4 4
-5 -5 -5
0 0 0
11 11 11
%CALC{"$SUM($ABOVE())"}% 10 10

Test Expected Actual
0 0 0
0 0 0
0 0 0
0 0 0
%CALC{"$SUM($ABOVE())"}% 0 0

SUMDAYS( list ) -- sum the days in a list or range of cells

  • The total number of days in a list or range of cells containing numbers of hours, days or weeks. The default unit is days; units are indicated by a h, hours, d, days, w, weeks suffix. One week is assumed to have 5 working days, one day 8 hours
  • Syntax: $SUMDAYS( list )
  • Example: %CALC{"$SUMDAYS(2w, 1, 2d, 4h)"}% returns 13.5, the evaluation of (2*5 + 1 + 2 + 4/8)
  • Related: $SUM(), $TIME(), $FORMATTIME()

SUMPRODUCT( list, list ) -- scalar product on ranges of cells

  • Syntax: $SUMPRODUCT( list, list, list... )
  • Example: %CALC{"$SUMPRODUCT(R2:C1..R4:C1, R2:C5..R4:C5)"}% evaluates and returns the result of ($T(R2:C1) * $T(R2:C5) + $T(R3:C1) * $T(R3:C5) + $T(R4:C1) * $T(R4:C5))
  • Related: $LIST(), $PRODUCT(), $SUM()

T( address ) -- content of a cell

  • Syntax: $T( address )
  • Example: %CALC{"$T(R1:C5)"}% returns the text in cell R1:C5
  • Related: $COLUMN(), $ROW()

TRANSLATE( text, from, to ) -- translate text from one set of characters to another

  • The translation is done from a set to a set, one character by one. The text may contain commas; all three parameters are required. In the from and to parameters you can write $comma to escape comma, $sp to escape space
  • Syntax: $TRANSLATE( text, from, to )
  • Example: %CALC{"$TRANSLATE(boom,bm,cl)"}% returns cool
  • Example: %CALC{"$TRANSLATE(one, two,$comma,;)"}% returns one; two
  • Related: $INSERTSTRING(), $LEFTSTRING(), $REPLACE(), $RIGHTSTRING(), $SUBSTRING(), $SUBSTITUTE()

TIME( text ) -- convert a date string into a serialized date number

  • Test: %CALC{"$TIME(2003/10/14 GMT)"}%
  • Expected: 1066089600
  • Actual: 1066089600

  • Test: %CALC{"$TIME(2009/05/10 GMT)"}%
  • Expected: 1241913600
  • Actual: 1241913600

  • Test: %CALC{"$TIME(10 May 2009 GMT)"}%
  • Expected: 1241913600
  • Actual: 1241913600

  • Test: %CALC{"$TIME(10 May 2009 GMT)"}%
  • Expected: 1241913660
  • Actual: 1241913660

TIMEADD( serial, value, unit ) -- add a value to a serialized date

  • The unit is seconds if not specified; unit can be second, minute, hour, day, week, month, year. Note: An approximation is used for month and year calculations
  • Syntax: $TIMEADD( serial, value, unit )
  • Example: %CALC{"$TIMEADD($TIME(), 2, week)"}% returns the serialized date two weeks from now
  • Related: $FORMATTIME(), $FORMATGMTIME(), $TIME(), $TIMEDIFF(), $TODAY()

TIMEDIFF( serial_1, serial_2, unit ) -- time difference between two serialized dates

TODAY( ) -- serialized date of today at midnight GMT

  • In contrast, the related $TIME() returns the serialized date of today at the current time, e.g. it includes the number of seconds since midnight GMT
  • Syntax: $TODAY( )
  • Example: %CALC{"$TODAY()"}% returns the number of seconds since Epoch
  • Related: $FORMATTIME(), $FORMATGMTIME(), $TIME(), $TIMEADD(), $TIMEDIFF()

TRIM( text ) -- trim spaces from text

  • Removes all spaces from text except for single spaces between words
  • Syntax: $TRIM( text )
  • Example: %CALC{"$TRIM( eat  spaces  )"}% returns eat spaces
  • Related: $EMPTY(), $EXACT(), $PROPERSPACE()

UPPER( text ) -- upper case string of a text

VALUE( text ) -- convert text to number

  • Extracts a number from text. Returns 0 if not found
  • Syntax: $VALUE( text )
  • Example: %CALC{"$VALUE(US$1,200)"}% returns 1200
  • Example: %CALC{"$VALUE(PrjNotebook1234)"}% returns 1234
  • Example: %CALC{"$VALUE(Total: -12.5)"}% returns -12.5
  • Related: $EVAL(), $INT()

WORKINGDAYS( serial_1, serial_2 ) -- working days between two serialized dates

The 4th column contains %CALC{"$WORKINGDAYS($TIME(2009/05/07), $TIME(2009/05/07))"}%

Note that the tests around March 2009 cross a Daylight Saving Time change.

Start End Expected Actual
2009/05/07 2009/05/07 0 0
2009/05/07 2009/05/08 1 1
2009/05/07 2009/05/09 1 2
2009/05/07 2009/05/10 1 2
2009/05/07 2009/05/11 2 2
2009/05/07 2009/05/12 3 3
2009/05/07 2009/05/13 4 4
2009/05/07 2009/05/14 5 5
2009/05/07 2009/05/15 6 6
2009/05/07 2009/05/16 6 7
2009/05/07 2009/05/17 6 7
2009/05/07 2009/05/18 7 7
2009/05/07 2009/05/20 9 9
2009/05/07 2009/05/21 10 10
2009/05/07 2009/05/22 11 11
2009/05/07 2009/05/23 11 12
2009/05/07 2009/05/24 11 12
2009/05/07 2009/05/25 12 12
2009/03/19 2009/03/19 0 0
2009/03/19 2009/03/20 1 1
2009/03/19 2009/03/21 1 2
2009/03/19 2009/03/22 1 2
2009/03/19 2009/03/23 2 2
2009/03/19 2009/03/24 3 3
2009/03/19 2009/03/30 7 7
2009/03/19 2009/03/31 8 8
2009/03/20 2009/03/20 0 0
2009/03/20 2009/03/21 0 1
2009/03/20 2009/03/22 0 1
2009/03/20 2009/03/23 1 1
2009/03/20 2009/03/24 2 2
2009/03/20 2009/03/30 6 6
2009/03/20 2009/03/31 7 7
2009/03/20 2009/04/01 8 8
2009/03/21 2009/03/21 0 0
2009/03/21 2009/03/22 0 0
2009/03/21 2009/03/23 1 0
2009/03/21 2009/03/24 2 1
2009/03/21 2009/03/25 3 2
2009/03/21 2009/03/30 6 5
2009/03/21 2009/03/31 7 6
2009/03/21 2009/04/01 8 7
2009/03/22 2009/03/22 0 0
2009/03/22 2009/03/23 1 0
2009/03/22 2009/03/24 2 1
2009/03/22 2009/03/25 3 2
2009/03/22 2009/03/30 6 5
2009/03/22 2009/03/31 7 6
2009/03/22 2009/04/01 8 7
2009/03/22 2009/04/02 9 8
2009/03/23 2009/03/23 0 0
2009/03/23 2009/03/24 1 1
2009/03/23 2009/03/25 2 2
2009/03/23 2009/03/26 3 3
2009/03/23 2009/03/27 4 4
2009/03/23 2009/03/28 4 5
2009/03/23 2009/03/29 4 5
2009/03/23 2009/03/30 5 5
2009/03/23 2009/03/31 6 6
2009/03/23 2009/04/01 7 7
2009/03/23 2009/04/02 8 8
2009/03/23 2009/04/03 9 9
2009/03/23 2009/04/04 9 10
2008/12/31 2009/12/31 261 261
Wersja tematu: r1. Ostatnia edycja: 2009-05-11, ProjectCoordinator. Stronę odwiedzono 585 razy.
 
O ile nie jest to stwierdzone inaczej, wszystkie materiały na stronie są dostępne na licencji Creative Commons Uznanie Autorstwa 3.0 Polska.
Pewne prawa zastrzeżone na rzecz Polskiej Partii Piratów. Serwis wykorzystuje oprogramowanie Foswiki na licencji GPL v2.