# Test Functions

Version:
Current

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

CompareDictionary(a,b): Compares 2 strings ignoring case differences, and compares text that appears to consist of numbers, in numerical order. The function returns -1 if a < b, 0 if a==b, and 1 if a > b.

This function 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

CompareDigits(a, b, nNumDigits): Compares 2 numbers and determines if they are the same to the given number of digits (nNumDigits).

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 parameter must not be null and must be between 1 and 19, otherwise, an error results. 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, 12445, 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

CompareEpsilon(a, b, epsilon): Compares 2 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

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

Name (v) IsEmpty
John False
True
Mary False
[Null] True

### IsInteger

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

#### Example

Value (v) IsInteger
1 True
1.23 False
B False

### IsNull

IsNull(v) : Tests if (v) is NULL. Returns True if v is NULL, otherwise returns False.

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

Name (v) IsNull
John False
[Null] True
Mary False

### IsNumber

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

### IsSpatialObj

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

### IsString

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

Running into problems or issues with your Alteryx product? Visit the Alteryx Community or contact support. Can't submit this form? Email us.