Test Functions

Version:
2019.3
Last modified: October 29, 2019

A test function performs data comparisons. Use a test function to identify the data type of a value, or determine if a value exists. A test function can be used on all data types.

CompareDictionary(a,b): Compares two strings ignoring case differences, and comparing text that appears to be numbers in numerical order. It returns -1 if a<b, 0 if a==b, and 1 if a>b. It is not exactly the same order as a dictionary compare, in that it does not handle diacritical marks the same way the Sort tool does when configured to do a dictionary sort using the conventions of a particular language.

Example

CompareDictionary(“apples”,”bananas”) returns -1

CompareDictionary(“APPLES”,”bananas”) returns -1

CompareDictionary(“apples”,”BANANAS”) returns -1

CompareDictionary(“Cherries”,”Bananas”) returns 1

CompareDictionary(“Bananas”,”bananas”) returns 0

CompareDictionary(“2”,”10”)  returns -1 (2 is less than 10, even though the character ‘2’ is greater than the character ‘1’)

CompareDictionary(“minus -2”,”minus -10”) returns 1 (-2 is greater than -10. Minus signs are only recognized at the beginning or after white space)

CompareDictionary(“minus-2”,”minus-10”) returns -1 (2 is less than 10. The minus sign, not being after a space, was not counted as part of the number)

CompareDictionary(“pi 3.14”,”pi 6.28e-1”) returns 1 (Yes, it recognizes floating point number syntax, and 3.14 is greater than 0.628)

CompareDictionary(“12.00”,”12.0”) returns 1 (When numbers have the same value, the longer string of digits is considered greater)

CompareDictionary(“a”, “À”) returns -1

CompareDictionary(“n”,” ñ”) returns -1 (letters with marks are larger, in the Latin alphabet, than all the un-marked letters)

CompareDictionary(“o”,” ñ”) returns -1 (In a Spanish Dictionary compare the Ñ should be less than O; this is not a linguistic dictionary comparison)

CompareDictionary(“ñ”,” Ñ”) returns 0 (marked characters compare ignoring case, too)

CompareDigits(a,b, nNumDigits): Compares two numbers and determines if they are the same to the given number of digits. The comparison finds the difference between the numbers and reports A and B the same when the leading digit of the difference is NumDigits or more places to the right of the digits of the larger of A and B.

The NumDigits argument must not be null, and must be between 1 and 19, otherwise an error will result. If a non-integer is given, it is rounded to the nearest integer. (NumDigits can be between 0.5 and 19.499)

Example

CompareDigits(12345, 12444, 3) returns "True" (because the difference is 99, and its leading digit is 3 places to the right of the leading digit of A)

CompareDigits(12345, 123445, 3) returns "False" (because the difference is 100, and its leading digit is only 2 places to the right of the leading digit of A)

CompareDigits(12.345, 12.347, 3) returns "True" (because the difference is 0.002, and its leading digit is 4 places to the right of the leading digit of A)

CompareDigits(12.345, 12.435, 3) returns "True" (because the difference is 0.09, and its leading digit is 3 places to the right of the leading digit of A)

CompareDigits( .91234, .91334, 3) returns “False” (because the difference is .001, and its leading digit is only 2 places to the right of the leading digit of A)

CompareEpsilon(a,b,epsilon): Compares two floating point numbers and returns true if they are within epsilon.

Example

CompareEpsilon([123.456789101112], [123.456789101114], 0.0001) returns "True"

CompareEpsilon([123.456], [123.456789101112],0.0001) returns "False"

IsEmpty(v): Tests if v is NULL or equal to "" or not

Example

Name IsEmpty
John False
  True
Mary False
[Null] True

IsInteger(v) : Tests if v contains a value that can be converted to an integer. If so, it will return true.

Example

Value IsInteger
1 True
1.23 False
B False

IsNull(v) : Tests if v is NULL or not

To populate a record with a NULL value, use the function NULL()

Example

Name IsNull
John False
[Null] True
Mary False

IsNumber(v) : Tests if the field type for v is a number or not.

IsSpatialObj(v): Tests if the field type for v is a spatial object or not.

IsString(v): Tests if the field type for v is a string or not.

Was This Helpful?

Need something else? Visit the Alteryx Community or contact support.