|
Page contents
- Syntax Rules
- Use CALC or CALCULATE
- Built-in Spreadsheet Plugin Functions
- ABOVE( ) -- address range of cells above the current cell
- ABS( num ) -- absolute value of a number
- ADDLIST( name, list ) -- append a list to a list variable
- AND( list ) -- logical AND of a list
- AVERAGE( list ) -- average of a list or a range of cells
- BIN2DEC( num ) -- convert a binary number to decimal
- BITXOR( text ) -- bit-wise XOR of text
- CEILING( num ) -- return the smallest integer following a number
- CHAR( number ) -- ASCII character represented by number
- CODE( text ) -- ASCII numeric value of character
- COLUMN( offset ) -- current column number
- COUNTITEMS( list ) -- count individual items in a list
- COUNTSTR( list, str ) -- count the number of cells
- DEC2BIN( num, width ) -- convert a decimal number to binary
- DEC2HEX( num, width ) -- convert a decimal number to hexadecimal
- DEC2OCT( num, width ) -- convert a decimal number to octal
- DEF( list ) -- find first non-empty list item or cell
- EMPTY( text ) -- test for empty text
- EQUAL( text1, text2 ) -- compare two text strings, case-insensitive
- EVAL( formula ) -- evaluate a simple mathematical formula
- EVEN( num ) -- test for even number
- EXACT( text1, text2 ) -- compare two text strings, case-sensitive
- EXEC( formula ) -- execute a spreadsheet formula
- EXISTS( topic ) -- check if topic exists
- EXP( num ) -- exponent (e) raised to the power of a number
- FILTER( expression, text ) -- filter out characters from text
- FIND( string, text, start ) -- find one string within another string
- FLOOR( num ) -- return the largest integer preceding a number
- FORMAT( type, precision, number ) -- format a number
- FORMATGMTIME( serial, text ) -- convert a serialized date
- FORMATTIME( serial, text ) -- convert a serialized date
- FORMATTIMEDIFF( unit, precision, time, option ) -- convert elapsed time
- GET( name ) -- get the value of a variable
- GETHASH( name, key ) -- get the value of a previously set hash key
- GETLIST( name ) -- get the list from a list variable
- HASH2LIST( name, format ) -- convert a hash to a list
- HASHCOPY( from, to ) -- copy a hash
- HASHEACH( formula, name ) -- evaluate and update each hash element
- HASHEXISTS( name, key ) -- test if a hash exists
- HASHREVERSE( name ) -- reverse a hash
- HEX2DEC( num ) -- convert a hexadecimal number to decimal
- HEXDECODE( hexcode ) -- convert hexadecimal code to string
- HEXENCODE( text ) -- encode text into hexadecimal code
- IF( condition, then, else ) -- return a value based on a condition
- INSERTSTRING( text, start, new ) -- insert a string into a text string
- INT( formula ) -- evaluate formula and return integer truncated towards 0
- ISDIGIT( text ) -- test for digits
- ISLOWER( text ) -- test for lower case text
- ISUPPER( text ) -- test for upper case text
- ISWIKIWORD( text ) -- test for WikiWord
- LEFT( ) -- address range of cells to the left of the current cell
- LEFTSTRING( text, num ) -- extract characters at the beginning
- LENGTH( text ) -- length of text in bytes
- LIST( range ) -- convert content of a cell range into a list
- LIST2HASH( name, list ) -- create a hash from a list
- LISTEACH( formula, list ) -- evaluate and update each element of a list
- LISTIF( condition, list ) -- remove elements from a list
- LISTITEM( index, list ) -- get one element of a list
- LISTJOIN( separator, list ) -- convert a list into a string
- LISTNONEMPTY( list ) -- remove all empty elements from a list
- LISTRAND( list ) -- get one random element of a list
- LISTREVERSE( list ) -- opposite order of a list
- LISTSHUFFLE( list ) -- shuffle element of a list in random order
- LISTSIZE( list ) -- number of elements in a list
- 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
- LOG( num, base ) -- logarithm of a number to a given base
- 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
- NOEXEC( formula ) -- do not execute a spreadsheet formula
- NOP( text ) -- no-operation
- NOT( num ) -- reverse logic of a number
- NOTE( text ) -- note, return empty string
- OCT2DEC( num ) -- convert an octal number to decimal
- ODD( num ) -- test for odd number
- OR( list ) -- logical OR of a list
- PERCENTILE( num, list ) -- percentile of a list or range of cells
- PI( ) -- mathematical constant Pi, 3.14159265358979
- PRODUCT( list ) -- product of a list or range of cells
- PROPER( text ) -- properly capitalize text
- PROPERSPACE( text ) -- properly space out WikiWords
- RAND( max ) -- random number
- RANDSTRING( set, format ) -- random string & password generator
- REPEAT( text, num ) -- repeat text a number of times
- REPLACE( text, start, num, new ) -- replace part of a text string
- RIGHT( ) -- address range of cells to the right of the current cell
- RIGHTSTRING( text, num ) -- extract characters at the end
- ROUND( formula, digits ) -- round a number
- ROW( offset ) -- current row number
- SEARCH( string, text, start ) -- search a string within a text
- SET( name, value ) -- set a variable for later use
- SETHASH( name, key, value ) -- set a hash value for later use
- SETIFEMPTY( name, value ) -- set a variable only if empty
- SETLIST( name, list ) -- save a list for later use
- SETM( name, formula ) -- modify an existing variable
- SETMHASH( name, key, formula ) -- modify an existing hash
- SIGN( num ) -- sign of a number
- SPLIT( separator, text ) -- split a string into a list
- SQRT( num ) -- square root of a number
- STDEV( list ) -- standard deviation based on a sample
- STDEVP( list ) -- standard deviation based on the entire population
- SUBSTITUTE( text, old, new, instance, option ) -- substitute text
- SUBSTRING( text, start, num ) -- extract a substring out of a text string
- SUM( list ) -- sum of a list or range of cells
- SUMDAYS( list ) -- sum the days in a list or range of cells
- SUMPRODUCT( list, list ) -- scalar product on ranges of cells
- T( address ) -- content of a cell
- TIME( text ) -- convert a date string into a serialized date number
- TIMEADD( serial, value, unit ) -- add a value to a serialized date
- TIMEDIFF( serial_1, serial_2, unit ) -- time difference
- TODAY( ) -- serialized date of today at midnight GMT
- TRANSLATE( text, from, to ) -- translate text
- TRIM( text ) -- trim spaces from text
- UPPER( text ) -- upper case string of a text
- VALUE( text ) -- convert text to number
- VAR( list ) -- variance based on a sample
- VARP( list ) -- variance based on the entire population
- WHILE( condition, do ) -- do something while a condition is true
- WORKINGDAYS( serial_1, serial_2 ) -- working days
- XOR( list ) -- logical XOR of a list
- FAQ
- CALC in Included Topics
- Bug Tracking Example
- Plugin Settings
- Plugin Installation Instructions
- Plugin Info
|
|
- Functions are evaluated from left to right, and from inside to outside if nested
- A function parameter can be text, a mathematical formula, a cell address, or a range of cell addresses
- Multiple parameters form a list; they are separated by a comma, followed by optional space, such as
%CALCULATE{$SUM( 3, 5, 7 )}%
|
|
< < |
- A parameter representing a string can optionally be enclosed in triple quotes; quotes are required if the string contains commas or parenthesis, such as
%CALCULATE{$SUBSTITUTE('''Good, early morning''', morning, day)}%
|
> > |
- A parameter representing a string can optionally be enclosed in triple quotes; quotes are required if the string contains commas, parenthesis or newlines, such as
%CALCULATE{$SUBSTITUTE('''Good, early morning''', morning, day)}%
- The
%CALCULATE{...}% variable may span multiple lines, which is useful to indent nested functions. In case the variable contains newlines, all white space around functions and function parameters is removed. Sample nested formula: %CALCULATE{ $LISTJOIN( $n, $LISTEACH( | $index | $item |, one, two, three ) ) }%
|
|
- A table cell can be addressed as
R1:C1 . Table address matrix: R1:C1 | R1:C2 | R1:C3 | R1:C4 | R2:C1 | R2:C2 | R2:C3 | R2:C4 |
|
| |
|
> > |
ADDLIST( name, list ) -- append a list to a list variable
- Specify the variable name (alphanumeric characters and underscores) and the list to add. If the named list does not exist it will be created. Useful in a FormattedSearch to add items to a list. This function returns no output. Use
$GETLIST() to retrieve a list variable.
- Syntax:
$ADDLIST( name, list )
- Example:
%CALCULATE{$SETLIST(nums, 0, 1, 2, 3)}% sets the nums variable to 0, 1, 2, 3 %CALCULATE{$ADDLIST(nums, 4, 5, 6, 7)}% adds 4, 5, 6, 7 to the nums variable %CALCULATE{$GETLIST(nums)}% returns 0, 1, 2, 3, 4, 5, 6, 7
- Example formatted search:
format="$percntCALCULATE{$ADDLIST(topics, $topic)}$percnt" in each search hit, adds the topic name to the topics list variable
- Related:
$GETLIST() , $SET() , $SETHASH() , $SETLIST()
|
|
AND( list ) -- logical AND of a list |
| FORMAT( type, precision, number ) -- format a number to a certain type and precision
- Supported
type :
-
COMMA for comma format, such as 12,345.68
|
|
> > |
-
-
CURRENCY for currency format, such as €12,345.68
- Negative numbers are shown in parenthesis, such as
(€6,789.00) for -6789
- The currency symbol is taken from the CURRENCYSYMBOL preferences setting, such as
US$ or $ for Dollar, € for Euro, ¥ for Yen, default $
|
|
-
-
DOLLAR for Dollar format, such as $12,345.68
|
|
> > |
-
-
- Negative numbers are shown in parenthesis, such as
($6,789.00) for -6789
|
|
-
-
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
|
|
- The
precision indicates the the number of digits after the dot
- Syntax:
$FORMAT( type, prec, number )
- Example:
%CALCULATE{$FORMAT(COMMA, 2, 12345.6789)}% returns 12,345.68
|
|
> > |
- Example:
%CALCULATE{$FORMAT(CURRENCY, 2, 12345.6789)}% returns $12,345.68
|
|
- Example:
%CALCULATE{$FORMAT(DOLLAR, 2, 12345.6789)}% returns $12,345.68
- Example:
%CALCULATE{$FORMAT(KB, 2, 1234567)}% returns 1205.63 KB
- Example:
%CALCULATE{$FORMAT(MB, 2, 1234567)}% returns 1.18 MB
|
|
- 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:
%CALCULATE{$GET(my_total)}% returns the value of the my_total variable
|
|
< < |
- Related:
$EXEC() , $GETHASH() , $LIST2HASH() , $HASH2LIST() , $NOEXEC() , $SET() , $SETHASH() , $SETIFEMPTY() , $SETM() , $SETMHASH() , $WHILE() , TWiki:Plugins.SetGetPlugin
|
> > |
- Related:
$EXEC() , $GETHASH() , $GETLIST() , $LIST2HASH() , $HASH2LIST() , $NOEXEC() , $SET() , $SETHASH() , $SETIFEMPTY() , $SETM() , $SETMHASH() , $WHILE() , SetGetPlugin
|
|
GETHASH( name, key ) -- get the value of a previously set hash key
- Specify the hash name and key; allowed characters for the hash name are alphanumeric characters, underscores and period. An empty string is returned if the hash key does not exist. Use
$SETHASH() or $LIST2HASH() to set a hash. If the key is omitted, a list of all keys of the named hash is returned. If no parameters are specified, a list of all hash names is returned.
- Syntax:
$GETHASH( name, key )
- Examples:
%CALCULATE{$SETHASH(age, Jane, 26)}% %CALCULATE{$SETHASH(age, Tim, 27)}% %CALCULATE{$GETHASH(age, Jane)}% returns 26 %CALCULATE{$GETHASH(age)}% returns Jane, Tim %CALCULATE{$GETHASH()}% returns age
|
|
< < | |
> > |
- Related:
$GET() , $GETLIST() , $HASH2LIST() , $HASHCOPY() , $HASHEACH() , $HASHEXISTS() , $HASHREVERSE() , $LIST2HASH() , $SET() , $SETHASH() , $SETMHASH()
GETLIST( name ) -- get the list from a list variable
- Specify the variable name (alphanumeric characters and underscores). An empty list is returned if the variable does not exist. Use
$SETLIST() or $ADDLIST() to set a variable.
- Syntax:
$GETLIST( name )
- Example:
%CALCULATE{$GETLIST(nums)}% returns the value of the nums variable
- Related:
$ADDLIST() , $GET() , $GETHASH() , $SETLIST() , SetGetPlugin
|
|
HASH2LIST( name, format ) -- convert a hash to a list |
|
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
|
> > |
- 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. If the value is omitted, the named variable is deleted.
|
|
- 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() , $GETHASH() , $HASH2LIST() , $LIST2HASH() , $NOEXEC() , $SETHASH() , $SETIFEMPTY() , SETM() , $SETMHASH() , $WHILE() , TWiki:Plugins.SetGetPlugin
|
> > |
- Related:
$EXEC() , $GET() , $GETHASH() , $HASH2LIST() , $LIST2HASH() , $NOEXEC() , $SETHASH() , $SETIFEMPTY() , $SETLIST() , SETM() , $SETMHASH() , $WHILE() , SetGetPlugin
|
|
SETHASH( name, key, value ) -- set a hash value for later use, or delete a hash |
|
- Example:
%CALCULATE{$SETHASH(age, Jane)}% deletes key Jane of hash named age
- Example:
%CALCULATE{$SETHASH(age)}% deletes hash named age
- Example:
%CALCULATE{$SETHASH()}% deletes all hashes
|
|
< < | |
> > |
- Related:
$GET() , $GETHASH() , $HASH2LIST() , $HASHCOPY() , $HASHEACH() , $HASHEXISTS() , $HASHREVERSE() , $LIST2HASH() , $SET() , $SETLIST() , $SETMHASH()
|
|
SETIFEMPTY( name, value ) -- set a variable only if empty |
|
- Example:
%CALCULATE{$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() , $SETHASH() , $SETMHASH()
|
|
> > |
SETLIST( name, list ) -- save a list for later use
- Specify the variable name (alphanumeric characters and underscores) and the list. This function returns no output. Use
$GETLIST() to retrieve a list variable. Use $ADDLIST() to add a list to an existing variable. If no list is specified, the named variable is deleted.
- Syntax:
$SETLIST( name, list )
- Example:
%CALCULATE{$SETLIST(octals, 0, 1, 2, 3, 4, 5, 6, 7)}% sets the octals variable to 0, 1, 2, 3, 4, 5, 6, 7
- Example:
%CALCULATE{$SETLIST(octals)}% deletes the octals variable
- Related:
$ADDLIST() , $GETLIST() , $SET() , $SETHASH() , SetGetPlugin
|
|
SETM( name, formula ) -- modify 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
|
| "form.name='FeatureForm'"
type="query"
nonoise="on" |
|
< < | format="$percntCALCULATE{$SETHASH(status, $topic, $formfield(Status))$SETHASH(summary, $topic, $summary(entityencode))$SETHASH(date, $topic, $date)}$percnt" |
> > | format="$percntCALCULATE{$SETHASH(status, $topic, $formfield(Status))$SETHASH(summary, $topic, '''$summary''')$SETHASH(date, $topic, '''$date''')}$percnt" |
| }%
Proposed Features
|
|
< < | |
> > | |
| Accepted Features
|
|
< < | |
> > | |
|
First we search all features and store the status, summary and date in hashes, using the topic name as the key. Then we build a table that shows all proposed features, followed by a table showing all accepted features. Reading the CALCULATE formula from inside out: |
|
- Do not handle
%CALC{}% variable in included topic while including topic: (default: 1) (See note CALC in Included Topics)
|
|
> > |
- Currency symbol. Specify
US$ or $ for Dollar, € for Euro, ¥ for Yen:
|
|
- WikiWords to exclude from being spaced out by the
$PROPERSPACE(text) function. This comma delimited list can be overloaded by a DONTSPACE preferences variable:
- Set DONTSPACE = CodeWarrior, MacDonald, McIntosh, RedHat, SuSE
|
|
|
|
< < |
|
> > |
|
|
|
|
< < |
Plugin Version: |
2013-10-10 |
|
> > |
Plugin Version: |
2014-09-23 |
|
| <--/twistyPlugin twikiMakeVisibleInline--> |
|
> > |
2014-09-23: |
TWikibug:Item7553 : Allow newlines and indent around functions and function parameters |
2014-09-22: |
TWikibug:Item7552 : Allow newlines in triple-quoted strings |
2014-03-04: |
TWikibug:Item7445 : Add FORMAT(CURRENY, ...) with support for currency symbol |
2014-01-22: |
TWikibug:Item7419 : Add ADDLIST(), GETLIST(), SETLIST() |
2014-01-22: |
TWikibug:Item7418 : Fix VALUE function bug with incorrect exponential number; ability to delete SET variable; do not strip trailing spaces in SETIFEMPTY |
|
|
|
|
< < |
2013-08-21: |
TWikibug:Item7322 : TRANSLATE supporting double quote and apostrophe-quote (single quote) excape tokens |
|
> > |
2013-08-21: |
TWikibug:Item7322 : TRANSLATE supporting double quote and apostrophe-quote (single quote) escape tokens |
|
|
2013-07-18: |
TWikibug:Item7299 : Add short and compact format to FORMATTIMEDIFF |
2013-06-20: |
TWikibug:Item7154 : Fix encoding of URL parameter in the interactive example so that $IF(1>2, true, false) works properly |
2013-05-21: |
TWikibug:Item7154 : Small doc fixes |
|