Skip to content

Function reference

A function is written with its name in square brackets, then its values, joined by words that read naturally: [round] amount to 2. Tests are written after is: account is a valid gstin. How functions fit into rules is explained in Writing rules and the rule language guide.

84 functions in 12 categories: Text · Text tests · Clean up · Missing values · Numbers · Amounts · Dates · Similarity · Tax and identifiers · Keys · Lists and ranges · Lookup tables

Text

WriteGivesWhat it does
[trim] texttextWithout spaces at the start and end
Example: [trim] reference
[trim start of] texttextWithout spaces at the start
Example: [trim start of] reference
[trim end of] texttextWithout spaces at the end
Example: [trim end of] reference
[lower case] texttextIn small letters
Example: [lower case] party
[upper case] texttextIn capitals
Example: [upper case] party
[title case] texttextFirst letter of each word in capitals
Example: [title case] party
[replace in] text, find with withtextEvery occurrence of a piece of text replaced
Example: [replace in] reference, '/' with '-'
[replace pattern in] text, pattern with withtextWhat a regular expression matches, replaced
Example: [replace pattern in] narration, '[0-9]+' with ''
[extract] pattern from texttextThe first part of the text a regular expression matches
Example: [extract] 'UTR[0-9]+' from narration
[join] value, value, …textValues joined into one text, missing ones left out
Example: [join] prefix, '-', number
[join with] separator, value, …textValues joined with a separator, blank ones left out
Example: [join with] '/', branch, account
[left] count of texttextThe first characters
Example: [left] 4 of reference
[right] count of texttextThe last characters
Example: [right] 4 of account
[characters] from to to of texttextCharacters from one position to another, counting from 1
Example: [characters] 3 to 8 of reference
[part] n of text by separatortextThe nth piece of the text split at a separator, counting from 1
Example: [part] 2 of narration by '/'
[length of] texta numberHow many characters
Example: [length of] reference
[pad left] text to length with charactertextFilled on the left up to a length
Example: [pad left] cheque to 6 with '0'
[pad right] text to length with charactertextFilled on the right up to a length
Example: [pad right] code to 8 with ' '
[reverse] texttextThe characters in reverse order
Example: [reverse] code

Text tests

WriteGivesWhat it does
text contains partyes or noWhether the text has the part in it, ignoring case
Example: narration contains 'NEFT'
text starts with startyes or noWhether the text starts with it, ignoring case
Example: reference starts with 'INV'
text ends with endyes or noWhether the text ends with it, ignoring case
Example: account ends with '001'
text contains any of part, …yes or noWhether the text has any of the parts in it, ignoring case
Example: narration contains any of 'SMS', 'CHG'
text matches patternyes or noWhether a regular expression finds a match in the text
Example: reference matches '^INV[0-9]+'

Clean up

WriteGivesWhat it does
[remove spaces from] texttextWithout any spaces
Example: [remove spaces from] account
[single spaces in] texttextTrimmed, runs of spaces turned into one
Example: [single spaces in] party
[digits of] texttextOnly the digits
Example: [digits of] cheque
[letters and digits of] texttextOnly letters and digits
Example: [letters and digits of] reference
[remove special characters from] texttextOnly letters, digits, underscores and spaces
Example: [remove special characters from] party
[remove punctuation from] texttextWithout punctuation
Example: [remove punctuation from] party
[remove accents from] texttextAccented letters as plain ones
Example: [remove accents from] party
[tidy] texttextUpper case, trimmed, single spaces
Example: [tidy] narration
[tidy name] texttextA name for comparing: capitals, letters, digits and single spaces
Example: [tidy name] party
[tidy phone] texttextOnly digits and +
Example: [tidy phone] phone
[tidy email] texttextTrimmed, in small letters
Example: [tidy email] email
[tidy reference] texttextCapitals and digits only
Example: [tidy reference] reference

Missing values

WriteGivesWhat it does
value is presentyes or noWhether there is a value: not missing and not blank
Example: reference is present
[first present of] value, value, …a valueThe first value that is present (not missing or blank)
Example: [first present of] utr, cheque, 'NONE'

Numbers

WriteGivesWhat it does
[number from] texta numberA number from text such as '1,250.50', '?500' or '(75.00)'
Example: [number from] column "Amount"
value is a numberyes or noWhether the value reads as a number
Example: column "Amount" is a number
[text of] valuetextThe value as text
Example: [text of] amount
[absolute] numbera numberWithout its sign
Example: [absolute] amount
[round] number to decimalsa numberRounded half up to the decimals
Example: [round] amount to 2
[round up] number to decimalsa numberRounded up to the decimals
Example: [round up] amount to 0
[round down] number to decimalsa numberRounded down to the decimals
Example: [round down] amount to 0
[sign of] numbera number1, 0 or -1
Example: [sign of] amount
[square root of] numbera numberThe square root
Example: [square root of] value
[power of] number to exponenta numberRaised to a power
Example: [power of] rate to 2

Amounts

WriteGivesWhat it does
[difference between] a and ba numberThe size of the difference, without sign
Example: [difference between] bank_amount and book_amount
[percent difference between] a and ba numberThe difference as a percentage of the second
Example: [percent difference between] invoice and payment
[within] tolerance of a and byes or noWhether two amounts differ by at most the tolerance
Example: [within] 1 of bank_amount and book_amount
[within percent] percent of a and byes or noWhether two amounts differ by at most a percentage of the second
Example: [within percent] 0.5 of invoice and payment

Dates

WriteGivesWhat it does
[today]a dateToday's date; also written today
Example: date is before today
[date of] valuea dateThe value read as a date (day first unless written year first)
Example: [date of] column "Value Date"
[date from] text as formata dateA date written in a given format
Example: [date from] value_date as 'MM/dd/yyyy'
value is a dateyes or noWhether the value reads as a date
Example: column "Value Date" is a date
[format] date as formattextA date written in a given format
Example: [format] date as 'MMM yyyy'
[days between] from and toa numberDays from the first date to the second
Example: [days between] invoice_date and payment_date
[year of] datea numberThe year
Example: [year of] date
[month of] datea numberThe month, 1 to 12
Example: [month of] date
[day of] datea numberThe day of the month
Example: [day of] date
[quarter of] datea numberThe calendar quarter, 1 to 4
Example: [quarter of] date
[start of month of] datea dateThe first day of its month
Example: [start of month of] date
[end of month of] datea dateThe last day of its month
Example: [end of month of] date
date is a weekendyes or noWhether the date is a Saturday or Sunday
Example: date is a weekend
date is a business dayyes or noWhether the date is Monday to Friday
Example: date is a business day

Similarity

WriteGivesWhat it does
[similarity of] a and ba numberHow alike two texts are, 0 to 1, ignoring case
Example: [similarity of] party and payee is at least 0.85
[characters different between] a and ba numberHow many characters must change to turn one into the other
Example: [characters different between] reference and utr is at most 2
[name similarity of] a and ba numberHow alike two names are, 0 to 1 (Jaro-Winkler)
Example: [name similarity of] party and payee is at least 0.9
[sound of] texttextA code for how a name sounds (Soundex)
Example: [sound of] party is [sound of] payee

Tax and identifiers

WriteGivesWhat it does
[tidy gstin] texttextA GSTIN in capitals without separators
Example: [tidy gstin] gstin
text is a valid gstinyes or noWhether the text is a well-formed GSTIN
Example: gstin is a valid gstin
[state code of gstin] texttextThe two-digit state code of a GSTIN
Example: [state code of gstin] gstin
[pan of gstin] texttextThe PAN inside a GSTIN
Example: [pan of gstin] gstin

Keys

WriteGivesWhat it does
[key of] value, value, …textValues joined with | into one key
Example: [key of] account, date
[fingerprint of] value, value, …textA SHA-256 fingerprint of the values
Example: [fingerprint of] date, amount, reference
[md5 of] texttextMD5 fingerprint
Example: [md5 of] reference
[sha256 of] texttextSHA-256 fingerprint
Example: [sha256 of] reference

Lists and ranges

WriteGivesWhat it does
value is one of option, …yes or noWhether the value is one of those listed
Example: status is one of 'OPEN', 'HELD'
value is between low and highyes or noWhether the value is from low to high, both included
Example: amount is between 0 and 500

Lookup tables

WriteGivesWhat it does
column of key in tablea valueA value from one of the workspace's lookup tables: the row whose key matches; 'default' when there is none
Example: the group of party in VENDORS default 'OTHER'
column for number in tablea valueA value from a range table: the row whose range holds the number
Example: the rate for amount in TDS_SLABS
key is in tableyes or noWhether a lookup table has the key
Example: account is in BLOCKED_ACCOUNTS
(value, value, …)textA key of several values, for tables keyed on more than one column
Example: the rate of (party, currency) in RATES