Expression Builder Operators
This table describes all of the operators available in the Expression Builder window that you use when working with the following:
■ Data filters
■ Business rules
■ Conditional statements
■ Attribute transformations
Operator Types
Operators are available for the following types:
■ Arithmetic. Performs mathematical equations.
■ Comparison. Compares values.
■ Logical. Performs operations that resolve to true or false or connects statements.
■ Set. Determines if a value is equal to one in a list of values.
■ String. Compares and concatenates string values.
Guidelines
When using operators in the Expression Builder, note the following guidelines:
■ When you create an expression statement, if you construct the expression to return as TRUE (1) you can then drill down to see the rows that failed.
■ To add operators in the Expression Builder, you either click icon buttons or select from the list of expression elements.
■ Operators are not case sensitive.
■ Operator keywords are added to expressions in blue text.
■ When using literal values such as "New York," enclose the value in double quotation marks. Attribute names and numeric values do not require quotation marks. Any numeric value enclosed in quotation marks, such as "123" will be read as a literal value.
■ When using the Expression Builder in a Quality project, note the following:
| ■ | Do not select "IF" to specify a condition. The "IF" part of the syntax is automatically generated. |
| ■ | There are a maximum of 100 nested IFs allowed in IF/ELSE conditional statements. |
| ■ | Adding multiple IF operators to the top level of a single conditional section is not supported. Include only one top-level IF (head-if) per section. |
Operator Descriptions
The following table includes operator descriptions, syntax, and examples of use. Click the
icon to view syntax and examples.
| Operator Name | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Arithmetic | |||||||||||||
| - | Subtract to find the difference of | ||||||||||||
| * | Multiplied by | ||||||||||||
| / | Divided by | ||||||||||||
| + |
Sum of
|
||||||||||||
| Comparison | |||||||||||||
| < | Less than | ||||||||||||
| <= | Less than or equal to | ||||||||||||
| !=, <> | Not equal to | ||||||||||||
| = | Is equal to | ||||||||||||
| > | Greater than | ||||||||||||
| >= | Greater than or equal to | ||||||||||||
| Logical | |||||||||||||
| AND |
A conjunction between two statements. Both statements must be true for the conjunction to be true. attribute1 = value1 AND attribute2 = value2 where attribute1 = value1 is the first statement to be joined. attribute2 = value2 is the second statement to be joined. Note the following guidelines: ■ AND can also be used with the OR and NOT operators. ■ Expressions are evaluated from left to right. Precedence is implied by the order shown in the expression, although parenthetical statements always take priority. ■ Any comparison operator can be used to join statements. ■ Statements are not case-sensitive. ■ The following associates the values tomato and fruit to attributes Name and Type: Name = "tomato" AND Type = "fruit" |
||||||||||||
| IF, THEN, ELSE |
Logical condition operators. The ELSE statement is optional. When using the Expression Builder inside a Quality project, do not select "IF" to specify a condition. The "IF" part of the syntax is automatically generated. IF expression1 THEN expression2 ELSE expression3 |TRUE|FALSE where expression is the condition or argument that completes the IF, THEN, ELSE logic. The ELSE statement takes an expression or the keywords "TRUE" or "FALSE". The following validates the value in the Auth Id Rep attribute: IF [Status] <> "AUTH" AND [Status] <> "REJECT" THEN [Auth Id Rep] = "NSP" ELSE TRUE |
||||||||||||
| IF, THEN, ELSE IF, THEN, ELSE |
Logical condition operators. Syntax is similar to the IF, THEN, ELSE logical statement. IF expression1 THEN expression2 ELSE IF expression3 THEN expression4 ELSE expression5 |TRUE|FALSE where expression is a condition or argument that completes the IF, THEN, ELSE IF, THEN, ELSE logic. The ELSE statement takes an expression or the keywords "TRUE" or "FALSE". The following validates the value in the Acc Type attribute: IF [Acc Type] IN (410) THEN SUBSTR([Acc Num],4,3) = "410"AND PATTERN(SUBSTR([Acc Num],1,3),"rich") = "d3" AND PATTERN(SUBSTR([Acc Num],7,8),"rich") = "d8" ELSE IF [Acc Type] IN (510) THEN SUBSTR([Acc Num],4,3) = "510" AND PATTERN(SUBSTR([Acc Num],1,3),"rich") = "d3" AND PATTERN(SUBSTR([Acc Num],7,8),"rich") = "d8" ELSE PATTERN([Acc Num], "rich") = "d20" |
||||||||||||
| NOT |
Reverses the truth value of the statement that follows, resulting in the opposite of the statement it evaluates. NOT attribute1 = value1 where attribute1 = value1 is the statement to be reversed. Note the following guidelines: ■ NOT can also be used with the AND and OR operators. ■ Expressions are evaluated from left to right. Precedence is implied by the order shown in the expression, although parenthetical statements always take priority. ■ Statements are not case-sensitive. ■ The following reverses (disconnects) the value "JOHN" from the attribute first_name: NOT(first_name="JOHN") ■ The following reverses (disconnects) the values tomato and fruit from the attributes Name and Type: NOT Name = "tomato" AND Type = "fruit" |
||||||||||||
| OR |
An inclusive disjunction between two statements. At least one statement must be true for the disjunction to be true. attribute1 = value1 OR attribute2 = value2 where attribute1 = value1 is the first disjunctive statement in the expression. attribute2 = value2 is the second disjunctive statement. Note the following guidelines: ■ OR can also be used with the AND and NOT operators ■ Expressions are evaluated from left to right. Precedence is implied by the order shown in the expression, although parenthetical statements always take priority. ■ Any comparison operator can be used to join statements. ■ Statements are not case-sensitive. ■ The following returns a correct value if either statement is true. If neither is true, no value is returned: age > 21 OR year_of_birth > 1990 ■ The following shows that either the value tomato is valid for the Name attribute or the value fruit is valid for the Type attribute: Name = "tomato" OR Type = "fruit" ■ The following expression validates that if the Sort Code attribute is populated, then it is correct for the country in the Client attribute:
|
||||||||||||
| Set | |||||||||||||
| IN |
Tests whether a value is equal to a value in a list. value IN ("value1","value2",..."valueN") OR value IN LIST("value1","value2",..."valueN") OR value IN "value1","value2",..."valueN" where ■ value is the value to be tested. ■ value1,value2,valueN are the values in the set to be tested for a match.
■ You can create a filter to return certain values. The statement Name IN ("tomato","pear") results in returning the rows where tomato or pear occur in the Name attribute. ■ You can create validation and business rules based on whether a value matches one of a set of values. For example, |
||||||||||||
| String | |||||||||||||
| LIKE |
Comparison operator that searches for a value that matches a specified pattern. value LIKE "pattern" where ■ value is the attribute to be searched. ■ "pattern" is the pattern used for the match. Note the following guidelines: ■ To broaden the match criteria, use the wildcard characters asterisk (*) and question mark (?), as follows:
■ Use square brackets ([ ]) to specify any one group of characters in a set; for example [a,b,c]. Use a dash (-) to specify a range of characters; for example, [1-10]. ■ If ATTR1 contains the values test and testing, the expression ATTR1 LIKE "tes?" returns "test". To return both "test" and "testing", use ATTR1 LIKE "tes*". ■ If ATTR2 contains the values "stick" and "stack", the expression ATTR2 LIKE "st[a-j]ck" returns both. ■ The following shows how to view all values in the NAME attribute that contain the string "cust": NAME LIKE "*cust*". ■ To find all Product identification numbers with a 5 in the 3rd position, use the following: Product_Id LIKE "??5*". |
||||||||||||
| || |
Concatenates multiple arguments (such as strings, attributes, and integers) with no space between each argument. argument1 || argument2 || argument3 where: ■ argument1 indicates the first argument in a series of concatenated arguments. ■ argument2 indicates the second argument in a series. ■ argument3 indicates the third argument, and so on. ■ "One" || ATX || 3 returns OneATX3. ■ "Nelson" || "Ruiz" returns "NelsonRuiz". ■ House No - 2 || House No - 1 results in 01 for all records. |
||||||||||||
| |: |
Concatenates multiple arguments (such as strings, attributes, and integers) with a space between each argument. argument1|: argument2 |: argument3 where ■ argument1 indicates the first argument in a series of concatenated arguments. ■ argument2 indicates the second argument in a series. ■ argument3 indicates the third argument, and so on. ■ "One" |: ATX |: 3 returns One ATX 3. ■ "Nelson |: Ruiz" returns "Nelson Ruiz". |
||||||||||||