The example expressions in this section illustrate correct syntax and the types of
expressions possible with CLEM.
Simple expressions
Copy link to section
Formulas can be as simple as this one, which derives a new field based on the
values of the fields After and Before:
(After - Before) / Before * 100.0
Copy to clipboardCopied to clipboard
Notice that field names are unquoted when referring to the values of the
field. Similarly, the following expression simply returns the log of each value for the field
salary.
log(salary)
Copy to clipboardCopied to clipboard
Complex expressions
Copy link to section
Expressions can also be lengthy and more complex. The following expression
returns true if the value of two fields ($KX-Kohonen and $KY-Kohonen) fall
within the specified ranges. Notice that here the field names are single-quoted because the field
names contain special characters.
('$KX-Kohonen' >= -0.2635771036148072 and '$KX-Kohonen' <= 0.3146203637123107
and '$KY-Kohonen' >= -0.18975617885589602 and
'$KY-Kohonen' <= 0.17674794197082522) -> T
Copy to clipboardCopied to clipboard
Several functions, such as string functions, require you to enter several
parameters using correct syntax. In the following example, the function subscrs is
used to return the first character of a produce_ID field, indicating whether an item is
organic, genetically modified, or conventional. The results of an expression are described by
-> `result`.
subscrs(1,produce_ID) -> `c`
Copy to clipboardCopied to clipboard
Similarly, the following expression is:
stripchar(`3`,`123`) -> `12`
Copy to clipboardCopied to clipboard
It's important to note that characters are always encapsulated within single
backquotes.
Combining functions in an expression
Copy link to section
Frequently, CLEM expressions consist of a combination of functions. The
following function combines subscr and lowertoupper to return the
first character of produce_ID and convert it to uppercase.
lowertoupper(subscr(1,produce_ID)) -> `C`
Copy to clipboardCopied to clipboard
This same expression can be written in shorthand as:
lowertoupper(produce_ID(1)) -> `C`
Copy to clipboardCopied to clipboard
Another commonly used combination of functions is:
locchar_back(`n`, (length(web_page)), web_page)
Copy to clipboardCopied to clipboard
This expression locates the character `n` within the values
of the field web_page, reading backward from the last character of the field value. By
including the length function as well, the expression dynamically calculates the
length of the current value rather than using a static number, such as 7, which will not be valid
for values with less than seven characters.
Special functions
Copy link to section
Numerous special functions (preceded with an @ symbol) are
available. Commonly used functions include:
@BLANK('referrer ID') -> T
Copy to clipboardCopied to clipboard
Frequently, special functions are used in combination, which is a commonly
used method of flagging blanks in more than one field at a time.
@BLANK(@FIELD)-> T
Copy to clipboardCopied to clipboard
Additional examples are discussed throughout this CLEM documentation. See
CLEM (legacy) language reference for more
information.
About cookies on this siteOur websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising.For more information, please review your cookie preferences options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.